Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2240550pxb; Mon, 23 Aug 2021 15:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoFhmbjEkwPZmoM/lrAtQyO1kqdFU607Zwe8SzSrBbdNaa5fXCBwmmYL73VjZ3l9ggsd7r X-Received: by 2002:a17:906:52d9:: with SMTP id w25mr6627343ejn.464.1629758570886; Mon, 23 Aug 2021 15:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629758570; cv=none; d=google.com; s=arc-20160816; b=XfrC2H7x4SgV1+WquxQZP9UL7kBFF/MkfkUTWxbIPA5ebfR72YAL/igD6sbAO0HQbR wuhsBh9pBIyeKvtiFubNfnMd4l5mCSCpw7WGrOczgL2D7iCTusTyW4bv/hmiYiwVyxee S0BFr6+eKx1GkDtJKevakI55bUi0gOtpCLZ5p8kKjdCeYaYkywb9TmDD5F7ceMkarmfg Dp4RJAr/uzIY1c+Dg+znyWkH7AwEGzv4rgi/+N85YjvT8mACfix3hgLCWbMIGolsMOs+ UPQ4aXvEJuJCvvSDCBZzCmSsOvD3z3RAyaLUh8vf8+G0eau8Xeb56wO01GIzMz2j4wNg f0Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=ZlrjGTozy+/BVVtSpbg+B9Oe1UkUPbISjCvvFGrqXlg=; b=wkpVxJnzAL/p6Cq8yeLSEnnzbh4z7FLXg3Wt58KvLKqSVCepQ+s5lWgRNnjsk7yo0y 9rjLNuTzQ5GysZ7YOmForoQHaJYQ/AMlvbz7spElagHrT6RcUTVoVpWwWHepmRd5hD/k C57xGL1vrj9YzNcw191/8prucg5jEICppKs9IrXJvZLeNDvmGuoaRnUtJeVNuEjMU610 Ug9Q728Qh7Hvv+xO9rtxPyepZLs89CuErf4Lccjht0V2c43pi20VPeEen4+cK/DPE5gm uq3xln6qUmB9XnTTlM5FDRY8hrgU7jpLDEpjnVXLzzqJxRhokpPJqBwabMsj4e0kfF7g Z/8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i32J3rbM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si15958901ejz.158.2021.08.23.15.42.27; Mon, 23 Aug 2021 15:42:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i32J3rbM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233219AbhHWWkd (ORCPT + 99 others); Mon, 23 Aug 2021 18:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbhHWWkc (ORCPT ); Mon, 23 Aug 2021 18:40:32 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8498AC061575 for ; Mon, 23 Aug 2021 15:39:49 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id q15-20020a056a0002af00b003e2840527ceso9264887pfs.11 for ; Mon, 23 Aug 2021 15:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=ZlrjGTozy+/BVVtSpbg+B9Oe1UkUPbISjCvvFGrqXlg=; b=i32J3rbMQ0H5p2G8SzukcQI43bhJ5ntJGGf9D1umNfUcjm8W8qmAUff5q99knxxmhM cOrfyLMTACMwCnr6/JTNAYsZOB+Z6zMT+JI7rp4n4CFLa96AaRVdRaM1hSOxh/QEA7vV TaB7c92L+cqN71A0+ry5+uV+4wwINpFXM60CyBmcu002rbGSDfSD4ue8iDsutymBWUa4 lKHK7r+J5l4ypKAL7ngZ8TxdJuow7jMseZYFdQ7R6px8OHRVbrA57nnxDuwLaNLpdGaM 92/7NEYOVBRIXntdNFYGN+oo4DC1jHue7z544/aAFko6812mFMK7Ot5FwbU1PmbPrkLd oYOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ZlrjGTozy+/BVVtSpbg+B9Oe1UkUPbISjCvvFGrqXlg=; b=WqTRtk46IgBQz6m2ez0xWvYoL/Q6jHWj+m/U+QaH4C+FFs/jaRhlYWubvfmFuhAQNj 6vMp/g3fbctIWIerS9QB4W6rzY9b1E8BhaDad+B/Kvww/UkX2iK0t5PQDW4JsMBViKDZ WlFSdG2Z71mrCAmawYsc1EnV3DtG0SkP/JsziFD2M7CXsc8MBp1t/sYJ14XEcMlviJOp Moq5Zs467oxw++g/ZGWlhFOkmzMUFzx8dvFtnYlKiSdCSqu53Ymt41MdfofueVCURUJ5 FX6Y62bf2ouvkqyj60XgIcVkjIpVGcojMG8TsUqJdpiT/1xC9FyvrnVX91tyXT/zUKdp HbQw== X-Gm-Message-State: AOAM5326iDEFYIUl6blyXg+CBShgVZvVEiNKpXJfiINNtswwGBsCSugK c5sdo6/TT+jyR3vKzNW+P6b8iPr9AtYr X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:90a:f10:: with SMTP id 16mr867207pjy.80.1629758388829; Mon, 23 Aug 2021 15:39:48 -0700 (PDT) Date: Mon, 23 Aug 2021 22:39:40 +0000 Message-Id: <20210823223940.1878930-1-rananta@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog Subject: [PATCH] KVM: arm64: Trim guest debug exception handling From: Raghavendra Rao Ananta To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The switch-case for handling guest debug exception covers all the debug exception classes, but functionally, doesn't do anything with them other than ESR_ELx_EC_WATCHPT_LOW. Moreover, even though handled well, the 'default' case could be confusing from a security point of view, stating that the guests' actions can potentially flood the syslog. But in reality, the code is unreachable. Hence, trim down the function to only handle the case with ESR_ELx_EC_WATCHPT_LOW with a simple 'if' check. Suggested-by: Marc Zyngier Signed-off-by: Raghavendra Rao Ananta --- arch/arm64/kvm/handle_exit.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 04ebab299aa4..275a27368a04 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -113,34 +113,20 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu) * guest and host are using the same debug facilities it will be up to * userspace to re-inject the correct exception for guest delivery. * - * @return: 0 (while setting vcpu->run->exit_reason), -1 for error + * @return: 0 (while setting vcpu->run->exit_reason) */ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu) { struct kvm_run *run = vcpu->run; u32 esr = kvm_vcpu_get_esr(vcpu); - int ret = 0; run->exit_reason = KVM_EXIT_DEBUG; run->debug.arch.hsr = esr; - switch (ESR_ELx_EC(esr)) { - case ESR_ELx_EC_WATCHPT_LOW: + if (ESR_ELx_EC(esr) == ESR_ELx_EC_WATCHPT_LOW) run->debug.arch.far = vcpu->arch.fault.far_el2; - fallthrough; - case ESR_ELx_EC_SOFTSTP_LOW: - case ESR_ELx_EC_BREAKPT_LOW: - case ESR_ELx_EC_BKPT32: - case ESR_ELx_EC_BRK64: - break; - default: - kvm_err("%s: un-handled case esr: %#08x\n", - __func__, (unsigned int) esr); - ret = -1; - break; - } - return ret; + return 0; } static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu) -- 2.33.0.rc2.250.ged5fa647cd-goog