From patchwork Thu Feb 3 17:41:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12734481 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 E6233C433F5 for ; Thu, 3 Feb 2022 17:44:40 +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=T37FRq0Gc4fBDVlkjwUvKaLwfzumM7LJ/mvAM3vSprU=; b=JMoKoUCznheD1XNqvJLYdX8TgZ 8DjcHIoyptZ56hatLocIrOES96KXipOaaz79EREIPwk4cZUMj8YPrjmmW4pAxOqsWMqij70ecV4Zg Zc+QGXKebE1E9JAa+IzBYI/KF5ND/NjEv6T/UdpCKW648R0yXOb4ETjlkf1ofmKLpWs43GM1NPX7j WBg22UJZPO9XRjgIlREq6/p7+jHPWQlXf7+1ZtVIFAk6iUPnKd8273MUnSmGyH766CRDhpFJXBvdH auG+y1q+9QGeTNbyBRpYJFSf33STQFbRdbezCFuYJCIsl2lVz9yb+uyR4cVj/1H4YLFhpHo8yddKH E4r7xQLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFg8R-002IeP-5l; Thu, 03 Feb 2022 17:43:07 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFg7S-002IFL-8k for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 17:42:07 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 2-20020a251302000000b006118f867dadso7281482ybt.12 for ; Thu, 03 Feb 2022 09:42:04 -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=x5tD24Fm1rwvMTOsASLM22AFSW2OawoOEHLwGQ9pDuc=; b=VqO8XHbAyLJ2tZ/5GGV07Lv8+Otgp2b4HXEJpAWIswlWiwrdoqvi8vWs6wFL2jgD0n 1Vej2KnZwNkNolZRflQhj+s0T1pg1WdwwIG+rGLP4BTyf/T08T7yN7C4SIaEdslOEPoI KKf+gUUGANaBn05ZhcDUO5b6rLCjXe/hkWpQtHlL1Aibo1be2J3Z8aHKvtJvw/TqstNU 90SNgQ/dORslJNj3zwhSpWq3eer+0sllJSQ0Pfcu13cOXXr0Ps6siAOA/t65GUPkRzMX h0LgAjLbVvmwKg0CIovvOg5CKRhNrja/c3DzkWvXZDDY+pDaV3lqb36AM28U9Nx04Tdp XSwg== 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=x5tD24Fm1rwvMTOsASLM22AFSW2OawoOEHLwGQ9pDuc=; b=RMp7rUn0GLc6ONJ2mrDQn3HS9sdFPs01Vdp9JGMbs+kVbpf3epl5mjQ5Fy0l91leMV pQLsU2XTxaGtIUh+ehI3q/YrumUQ0WbzhN51x7pboXV4997J+CuPABV3r/sdNTAUGdOH Yb5JNYamfoxNwx2fqSIzqdu8qKfXpTW94Wu9oBsKis0Ww5dDp+BQtWzBycKMIoKlgRja EnArke46vGVx5FFcV2ANp5K0uDIcyBMHRVcNdcgbFyeZ4BDVGe0rhiG7ZYiEOBnwfq9R Eaf/Vqwwtfxryg0+fAjgsTRGQ98T0krzWbt76QAj8tEMBTmhLW+jItmHRZFJ1V5aUDle Qd3A== X-Gm-Message-State: AOAM533G116mH52fN0Q0QSREWOo2NAi3kl/5qM6KdUkZIjFwJGQDvcyg Tu12pH0f0VHlz/b+oX9SjSt+vLHyxTg= X-Google-Smtp-Source: ABdhPJzjipG+LZdF5GKOtsltb9S8zXEjr6pV/0RmHZ+YGaUkd3Q7Jy3LB0RxNWMlPEsYdiA5+sBM+SojxyY= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a0d:c7c6:: with SMTP id j189mr5174886ywd.395.1643910123903; Thu, 03 Feb 2022 09:42:03 -0800 (PST) Date: Thu, 3 Feb 2022 17:41:54 +0000 In-Reply-To: <20220203174159.2887882-1-oupton@google.com> Message-Id: <20220203174159.2887882-2-oupton@google.com> Mime-Version: 1.0 References: <20220203174159.2887882-1-oupton@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v5 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 , Mark Rutland , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_094206_375197_54C73174 X-CRM114-Status: GOOD ( 11.69 ) 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 Writes to OSLSR_EL1 are UNDEFINED and should never trap from EL1 to EL2, but the kvm trap handler for OSLSR_EL1 handles writes via ignore_write(). This is confusing to readers of code, but should have no 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. Reviewed-by: Reiji Watanabe Reviewed-by: Mark Rutland [adopted Mark's changelog suggestion, thanks!] 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 4dc2fba316ff..85208acd273d 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;