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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 74333C433F5 for ; Wed, 15 Dec 2021 11:41:26 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t9HK3k3P/XyhJpGlVXgmugQLHWSBu8nG+m5wRMdoq+E=; b=hhlvSXC1b2pJWR 6vzAxnf4d710Y4LUmjmTBB9aLBiPWvflPfhu1OSgJu5xDfbG+PPJNAtYAIzSKgzjxLC7ebffUX3yY gI2bvpS6yZeTPcGaOG6myd9Jz9FFzjOm5Um5/cMeYRHYHrD0hUU6zIGHccvpNQ8z+TSA7u2IWQ8lc L8QxERoI4rJHVpLKbbB83CWLLpX2dtGAlhOmgfMo5ZC2SG4HOyKPJCdW1hUgur0LRIGk9rPvgJag3 4patWd98mulMUJRpbTdQ8vk7cGF5Kk6O/NsmvfxVLidGR/cned/TY07gH69yw6Q/yFR2Tp6xT+eSU 0SBRxOfzLty+Z96vFglQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSdj-000d8I-If; Wed, 15 Dec 2021 11:40:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSdf-000d7X-Nq for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:40:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1807BD6E; Wed, 15 Dec 2021 03:40:02 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.67.176]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 038E83F774; Wed, 15 Dec 2021 03:40:00 -0800 (PST) Date: Wed, 15 Dec 2021 11:39:58 +0000 From: Mark Rutland To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Marc Zyngier , Peter Shier , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 1/6] KVM: arm64: Correctly treat writes to OSLSR_EL1 as undefined Message-ID: References: <20211214172812.2894560-1-oupton@google.com> <20211214172812.2894560-2-oupton@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211214172812.2894560-2-oupton@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_034003_850827_4FA81011 X-CRM114-Status: GOOD ( 21.28 ) 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 Hi Oliver, On Tue, Dec 14, 2021 at 05:28:07PM +0000, Oliver Upton wrote: > Any valid implementation of the architecture should generate an > undefined exception for writes to a read-only register, such as > OSLSR_EL1. Nonetheless, the KVM handler actually implements write-ignore > behavior. > > Align the trap handler for OSLSR_EL1 with hardware behavior. If such a > write ever traps to EL2, inject an undef into the guest and print a > warning. I think this can still be read amibguously, since we don't explicitly state that writes to OSLSR_EL1 should never trap (and the implications of being UNDEFINED are subtle). How about: | Writes to OSLSR_EL1 are UNDEFINED and should never trap from EL1 to EL2, but | the KVM trap handler for OSLSR_EL1 handlees writes via ignore_write(). This | is confusing to readers of the code, but shouldn't have any functional impact. | | For clarity, use write_to_read_only() rather than ignore_write(). If a trap | is unexpectedly taken to EL2 in violation of the architecture, this will | WARN_ONCE() and inject an undef into the guest. With that: Reviewed-by: Mark Rutland Mark. > Reviewed-by: Reiji Watanabe > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/sys_regs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index e3ec1a44f94d..11b4212c2036 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -292,7 +292,7 @@ static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, > const struct sys_reg_desc *r) > { > if (p->is_write) { > - return ignore_write(vcpu, p); > + return write_to_read_only(vcpu, p, r); > } else { > p->regval = (1 << 3); > return true; > -- > 2.34.1.173.g76aa8bc2d0-goog > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel