From patchwork Tue Nov 2 09:46:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12598263 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83DCBC433EF for ; Tue, 2 Nov 2021 09:48:42 +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 5341F60296 for ; Tue, 2 Nov 2021 09:48:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5341F60296 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: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=7I21kzo0LfSUeow2uoQjK0iU9rPoM1pkFjomc+9xVgw=; b=2Eu8ViYujUGr8lftREEnkMJH3P KMFgDF2DY7RWyI1jm3WQlkYOz7otvdaKqv7fvKuW1TqrTJ1Q+QsHoAXMdftvYm44Fi9MCFVwEE8z0 Juk8kXlTycGpaDZMKkmBAnRYS7eY0pElmj0NX7dFnAGqjiYBcuFF2x9zGAEVw1M5p1Y0LoL3X+QuG C1Lcx8eniBNDEEBY+gWiSbcBwHmQqGuaUuLQWpieT9z1zBSzsjptZIGEq0Y16y7QFNDZCPjZFbUxH KvblxiOA5Hd3BuPnvsVjHHECDX3+rAln7ZCCgY9vf8gNZw/PbwrbBegTMbW8H1gldda41PIIqxHLq ma0lRlNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhqNx-0018tA-PW; Tue, 02 Nov 2021 09:47:17 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhqNj-0018mE-Nh for linux-arm-kernel@lists.infradead.org; Tue, 02 Nov 2021 09:47:05 +0000 Received: by mail-io1-xd4a.google.com with SMTP id w8-20020a0566022c0800b005dc06acea8dso14710261iov.4 for ; Tue, 02 Nov 2021 02:47:01 -0700 (PDT) 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=1y+OLvxpVymtlL7fk66XN2cWX+vD2iLWE/0SkTIcu/U=; b=rzO1Y8VN0zUYuasfFoTvV/5jD+cKSRGlj/YpHnnIRuicH7JJIZ2PnY4j26AX38M33j w4phFGdJUTdXdCnx01ZxlpdHwuiZsF8zMYKIkTwU+Oz5ByP6W796mfarWTsctdFT1yL5 pJlkmLGyfKzIN/D3syWMWYGFIs5YynzA0lsENVBa/R/bjXWIMJgrWc22lyZuS7vFVIUg Ry7VLJisteieRR96iKby/wvJE7vRkjfUTAUGZdOcr7NC6SQDX3vX+NM/RDeG4U1iWDnV FRGpQZQSdtyOqQAjD/sUYy8cu81WON1vWgsJcY7wvINgJ71tv806zzkalWbjsCPfged8 +yUw== 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=1y+OLvxpVymtlL7fk66XN2cWX+vD2iLWE/0SkTIcu/U=; b=njYJoBdkFfDR8J24YJgXlSFNy730kqdr15KJrERyhdClwc7eNu2R7O5zbRcXfX3NAG BxLXs3bTUPpQwZIca1ZMZ0bFafiJhqc3ZNbk3w3qeKCA5MbiPMsHoKBCypUpBh0zS4Qe kIMKR0gzpFQXIvhJBKdomFFxVZ6V9BoN/ZNhmJKR3w7XyX+jvyGrrMIYUTcDdE2J8g7G b4H0HGxYoPzx8nHMJhvRfZ7ts81KMW3CbJDWpasn3QR5A/ffV28gHdrzed2PLUc32EL/ y5MHOXOOrABqPQWRKakCfUBy4Q5cAWzGNfAWIgtgJJdgqDXhocH0ex9/NE8HY2McU4zX tpXw== X-Gm-Message-State: AOAM532a66YI0H+mDTYJ3sVMc1KBxQhUJ2nvGLF+F6Q6RxHbRPWuHOok FDNeU+kwTbd65vktBGPb6QC92wOhqH4= X-Google-Smtp-Source: ABdhPJyayLrRnzjr+V0pA0yQ0Z4XEZRHuv5UbfBHmBUD+1GNwyAnZEMt4nk99gXUFzj3J+ZkE8WGDda50ZA= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6602:148b:: with SMTP id a11mr26232858iow.85.1635846420975; Tue, 02 Nov 2021 02:47:00 -0700 (PDT) Date: Tue, 2 Nov 2021 09:46:46 +0000 In-Reply-To: <20211102094651.2071532-1-oupton@google.com> Message-Id: <20211102094651.2071532-2-oupton@google.com> Mime-Version: 1.0 References: <20211102094651.2071532-1-oupton@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v2 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-20211102_024703_792666_58D0F00D X-CRM114-Status: GOOD ( 12.62 ) 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. Signed-off-by: Oliver Upton Reviewed-by: Reiji Watanabe --- 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 1d46e185f31e..17fa6ddf5405 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;