From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44D95C4338F for ; Mon, 23 Aug 2021 22:42:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D8F56136F for ; Mon, 23 Aug 2021 22:42:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0D8F56136F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=nda+XqOxbft4n/EEDMZymx8wL6B651Rr3qSMcWE6/IM=; b=JQC hOT/NoY3ifZ+rhrRDyvYm7CcAGNXjcqG8dCQHMHAX903KcG5tQ0/CQZoQ7lWECqvOsXRb6HTVrMN8 060A2ybasSRon4lCKWN6ATozzjKUlj1HR87b2taZCrFhWEuToU68lrg8t/soYpmEeSem5p0alMeSj FR5C2UdSBUbOiyoBxYxx+dBRhmrpbmDpd/QwcKWZ0/ps4scqzZaDXHTaYMNUgc4MxUAF9uZmxTI5A RgnEFBDlux3A4mJo1lre61gZ/ahaHJUepkR88jq1LhAGE7EhWgN6uvoDOzeX/TVzNm+JY7MCxfVcv VnjgKRE7oA3I3bPk2afQs1kFX8b1WjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIIbi-000sbH-GX; Mon, 23 Aug 2021 22:39:54 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIIbe-000sZx-NO for linux-arm-kernel@lists.infradead.org; Mon, 23 Aug 2021 22:39:52 +0000 Received: by mail-pj1-x104a.google.com with SMTP id y3-20020a17090a8b03b02901787416b139so656834pjn.4 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=TpVcfAJEEiwVmu8pXYooZIUWVHqheU0573UYiibgb8+ohkltQJA0Cx62bRHhTX6MXs cYSE2yZTdBgFQbVInFxrEqoEf+c1sTqh1zmaTnFbBIJ0s7Ug1upSUrUIQKVSHH2eeWYG jS9ALTl18SDLRa2RAHzuajrAiMBylc/8eSN6hvTqLrUup3ZuhhWxJ6N5P/+JUVjUp0aM ZMJjsM4l4R/bFNT726G/Cjkq5MH3VbbNOadsFatZgzONQc1w5W4nI0Y/O+o6v5CJjVQk owTeQ9OANfFMLxPacKe183CG9Gf3fgR4kHS89et7mXL4eCUrIWLudWQUB9HWZ5WiacER 5qPQ== X-Gm-Message-State: AOAM530t+b33X8FTUTcOnenzCFbHCmSEkGxe+hSC3rvlDcHyyHmt4QHP 3f/qPtzSx1BNs2o0woaKUTSUfwlqOrcs X-Google-Smtp-Source: ABdhPJxASietCIf57TllHwMPHW6IS8WL5h/EM1B0OToCNPzrClc7aA47+ufW1g4K95UEciNGRGi3rYMtLrzn 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210823_153950_832180_90723CFE X-CRM114-Status: GOOD ( 14.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel