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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id B913DC433EF for ; Mon, 29 Nov 2021 11:51:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 38E7B4B21E; Mon, 29 Nov 2021 06:51:06 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kOWTww9n2Y9w; Mon, 29 Nov 2021 06:51:04 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7AEC64B22E; Mon, 29 Nov 2021 06:51:04 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E86E14B21E for ; Mon, 29 Nov 2021 06:51:03 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rIDAlHp-LoOX for ; Mon, 29 Nov 2021 06:51:02 -0500 (EST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id DA3664B216 for ; Mon, 29 Nov 2021 06:51:02 -0500 (EST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B52E6612DD; Mon, 29 Nov 2021 11:51:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B639DC004E1; Mon, 29 Nov 2021 11:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638186660; bh=lrK+a3jcmhGjZtxTNTcoM9mfBFGiWHtUo3XC+pCiPbM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Wm4oHoBahW9bOxUD93ohtlHGMO6RsgOq8vTONwttdz0Ughf/4KfMbQGNtYrRJmIuM 2VSIhn4nX8E+u2L97L92kDYzRPtN1pxg7EhlipeU8ul/Zi1GwAyUvbmNppIffWms95 E/6DHycLLY7DYvgnTYLQLJ/O0/d+6zmNKPziDEH1J4sxA1ULcVcGd8OfXYOpkNMy+d KzoRAaEaNqABaEtOJm/EdT94nUTbLvBepgjFuVcXF53GtEnUbRZL+CYagKmKW7AAMR Lnv+KLyUWAT9R3ffRG4ZP26MJLQHlguCk0Jj9DNxavKxspqqjT869z3N36JyqRhz/+ ugu/MSHGkp7og== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mrfBS-008agL-N5; Mon, 29 Nov 2021 11:50:58 +0000 Date: Mon, 29 Nov 2021 11:50:58 +0000 Message-ID: <87sfvfmb8d.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Subject: Re: [PATCH v3 3/6] KVM: arm64: Allow guest to set the OSLK bit In-Reply-To: <20211123210109.1605642-4-oupton@google.com> References: <20211123210109.1605642-1-oupton@google.com> <20211123210109.1605642-4-oupton@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oupton@google.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, drjones@redhat.com, pshier@google.com, ricarkol@google.com, reijiw@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kvm@vger.kernel.org, Peter Shier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tue, 23 Nov 2021 21:01:06 +0000, Oliver Upton wrote: > > Allow writes to OSLAR and forward the OSLK bit to OSLSR. Do nothing with > the value for now. > > Reviewed-by: Reiji Watanabe > Signed-off-by: Oliver Upton > --- > arch/arm64/include/asm/sysreg.h | 6 ++++++ > arch/arm64/kvm/sys_regs.c | 33 ++++++++++++++++++++++++++------- > 2 files changed, 32 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h > index 16b3f1a1d468..9fad61a82047 100644 > --- a/arch/arm64/include/asm/sysreg.h > +++ b/arch/arm64/include/asm/sysreg.h > @@ -129,7 +129,13 @@ > #define SYS_DBGWCRn_EL1(n) sys_reg(2, 0, 0, n, 7) > #define SYS_MDRAR_EL1 sys_reg(2, 0, 1, 0, 0) > #define SYS_OSLAR_EL1 sys_reg(2, 0, 1, 0, 4) > + > +#define SYS_OSLAR_OSLK BIT(0) > + > #define SYS_OSLSR_EL1 sys_reg(2, 0, 1, 1, 4) > + > +#define SYS_OSLSR_OSLK BIT(1) > + > #define SYS_OSDLR_EL1 sys_reg(2, 0, 1, 3, 4) > #define SYS_DBGPRCR_EL1 sys_reg(2, 0, 1, 4, 4) > #define SYS_DBGCLAIMSET_EL1 sys_reg(2, 0, 7, 8, 6) > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 7bf350b3d9cd..5dbdb45d6d44 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -44,6 +44,10 @@ > * 64bit interface. > */ > > +static int reg_from_user(u64 *val, const void __user *uaddr, u64 id); > +static int reg_to_user(void __user *uaddr, const u64 *val, u64 id); > +static u64 sys_reg_to_index(const struct sys_reg_desc *reg); > + > static bool read_from_write_only(struct kvm_vcpu *vcpu, > struct sys_reg_params *params, > const struct sys_reg_desc *r) > @@ -287,6 +291,24 @@ static bool trap_loregion(struct kvm_vcpu *vcpu, > return trap_raz_wi(vcpu, p, r); > } > > +static bool trap_oslar_el1(struct kvm_vcpu *vcpu, > + struct sys_reg_params *p, > + const struct sys_reg_desc *r) > +{ > + u64 oslsr; > + > + if (!p->is_write) > + return read_from_write_only(vcpu, p, r); > + > + /* Forward the OSLK bit to OSLSR */ > + oslsr = __vcpu_sys_reg(vcpu, OSLSR_EL1) & ~SYS_OSLSR_OSLK; > + if (p->regval & SYS_OSLAR_OSLK) > + oslsr |= SYS_OSLSR_OSLK; > + > + __vcpu_sys_reg(vcpu, OSLSR_EL1) = oslsr; > + return true; > +} > + > static bool trap_oslsr_el1(struct kvm_vcpu *vcpu, > struct sys_reg_params *p, > const struct sys_reg_desc *r) > @@ -309,9 +331,10 @@ static int set_oslsr_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > if (err) > return err; > > - if (val != rd->val) > + if ((val & ~SYS_OSLSR_OSLK) != rd->val) > return -EINVAL; This looks odd. It means that once I have set the lock from userspace, I can't clear it? Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm