From patchwork Tue Dec 14 17:28:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12696097 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 7E0C5C433F5 for ; Tue, 14 Dec 2021 17:29:55 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=v5l/uIJJZuMy/zvlHpv9UOy0RjGsuY0zqD4UcVjwY0Y=; b=jyfSd3hebAWGs5IAsB4srzkVL0 PTx6y5DolKg+ItUjjcxGv/GjR5iwiZFkhoG2/XaAqc1x3wMQgH+6PTEUKPre1ywCfAmy4uZB7wM2j 8XS+pAWQ5un9Wlai1iG55I15AViYwVThAdL/8DDDxAUn2jJ8ETLAS4PniZLvSNI+C6N3nNfDQQFcf X+c7Fgw4zjDI1/sOLh5VSmWo9oiQG+Wkd456P5529n7MKKRxiCYKqxfBgADLH9e2SjbyNUYDOEywc dsxze2Hdlso4mHXVd1PS+F7hAqPapZmShRAULSfMii/D/nfdcfiltHrcopgPSnki1u13XZbaJuqY+ IBY/SsQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxBbO-00F6b6-N9; Tue, 14 Dec 2021 17:28:34 +0000 Received: from mail-il1-x149.google.com ([2607:f8b0:4864:20::149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxBbA-00F6UZ-2O for linux-arm-kernel@lists.infradead.org; Tue, 14 Dec 2021 17:28:21 +0000 Received: by mail-il1-x149.google.com with SMTP id g14-20020a92c7ce000000b002b1e78da1f9so594125ilk.21 for ; Tue, 14 Dec 2021 09:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EylPoIwJHu5cp6KovczhslrKEkEYeADu9LS/s52w9YE=; b=WptfY3NUSXg/+ge/bSycAdDXNGBatjC9Ty3fRvRO/naZtajLtOnCel1J92sJl+ffyB gn+26lozgkVnDFQXpBa6gsCcYi+iyY4OuU7RAGOitBJmuO5NpueNu8HQNe2wJsQlV6mb s7HQwUbg5T382xCMHMjdkKxRgEijgNNkXxlDoC+ukK9aQYxusDSDlIbvu7hlEhqY3DzV PXKES3uS5RaC0dZXWqfEbw+aUVIHfHv1KsCCPV6Bv9GfSPLPIO74l8okr9dVLvECSxr6 aLA1+JI2wnVQl0R+IFRqmZ5wRbK2MPHwT1vTHXV+IlorXhALZmCfzJ++Gt7rw6BYo9I0 i7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EylPoIwJHu5cp6KovczhslrKEkEYeADu9LS/s52w9YE=; b=acGWxDpv3OXPdqhlvkc2WbsCyBm2tdzIBEQ6XpcypNngsxjwPtZZqgEHFtNpILrTwc ZQamLvFUzyYduXbG+YLt8wn0WKayr6CS3dctwBJSBm7A9r1FfVqU8eqSsXtQ1MCOwcEP gEnmtIf+Pxp04MM/vGben0sYD7xTbkBVTIFa/TVuxEmmofP0Rzw6lVCPrVOa61WsvL7Q OZNyJL8mPWrESH+pAeRjNY6/BDBfZ++060J7kTkN+pnQb1R/LWPo+fxgiKBG4oaaGBCw 7YR0vLj3uGh2Wi5ZxLYAFTGa4OnnuabyIk80y0qnocZHWSjRphQksyrtC6+tjMUNBS6V kEGw== X-Gm-Message-State: AOAM532vmOWHUIMK/z41g3ciHB/MpMFgR9FZU4n6zIdBc+aZAaDqBVpl LH2STtBSd3g7WCmum7wkxECGmBnOA3g= X-Google-Smtp-Source: ABdhPJxlHuYVYQeqSWOyzJfDt70mmril4aeZVLx8iWFQhBCjg4s0ijgzuxjSVPZcN3dObuSd5rcGMlUpWSY= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6602:2d84:: with SMTP id k4mr4567077iow.168.1639502898040; Tue, 14 Dec 2021 09:28:18 -0800 (PST) Date: Tue, 14 Dec 2021 17:28:07 +0000 In-Reply-To: <20211214172812.2894560-1-oupton@google.com> Message-Id: <20211214172812.2894560-2-oupton@google.com> Mime-Version: 1.0 References: <20211214172812.2894560-1-oupton@google.com> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog Subject: [PATCH v4 1/6] KVM: arm64: Correctly treat writes to OSLSR_EL1 as undefined From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Peter Shier , Ricardo Koller , Reiji Watanabe , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211214_092820_137213_98BAE5ED X-CRM114-Status: GOOD ( 11.75 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Reviewed-by: Reiji Watanabe Signed-off-by: Oliver Upton Reviewed-by: Mark Rutland --- 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;