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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81A62C636CC for ; Tue, 31 Jan 2023 22:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbjAaWKM (ORCPT ); Tue, 31 Jan 2023 17:10:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231743AbjAaWKG (ORCPT ); Tue, 31 Jan 2023 17:10:06 -0500 Received: from out-92.mta0.migadu.com (out-92.mta0.migadu.com [IPv6:2001:41d0:1004:224b::5c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0AF5A824 for ; Tue, 31 Jan 2023 14:10:04 -0800 (PST) Date: Tue, 31 Jan 2023 22:09:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1675203002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=S8R6dRX63xPA5DjHb6DqdmOndQN9/0JU0PO7uTkzMT8=; b=qVKIj7kinVwdF8Mibg20xjp5SP+3XncPl/VnhOIgFPsIBFPYg/Wz5LjiPw+76hW9D15kgF Ur4P2Iy1ZGUoCMTWQ0qf78aJW7g0mkBlzvbdXLQysDmtpe/HfOwi/Hxc6N44OzTF/GbT+a AB+Pi6Gh/Wwxb+QGWsfKEmXSbtyxhoM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexandru Elisei , Andre Przywara , Chase Conklin , Christoffer Dall , Ganapatrao Kulkarni , Jintack Lim , Russell King , James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH v8 09/69] KVM: arm64: nv: Reset VMPIDR_EL2 and VPIDR_EL2 to sane values Message-ID: References: <20230131092504.2880505-1-maz@kernel.org> <20230131092504.2880505-10-maz@kernel.org> <87zg9ycqdj.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zg9ycqdj.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Jan 31, 2023 at 10:04:40PM +0000, Marc Zyngier wrote: > On Tue, 31 Jan 2023 20:17:50 +0000, Oliver Upton wrote: > > > > On Tue, Jan 31, 2023 at 09:24:04AM +0000, Marc Zyngier wrote: > > > From: Christoffer Dall > > > > > > The VMPIDR_EL2 and VPIDR_EL2 are architecturally UNKNOWN at reset, but > > > let's be nice to a guest hypervisor behaving foolishly and reset these > > > to something reasonable anyway. > > > > Must we be so kind? :) > > > > In all seriousness, I've found the hexspeak value of reset_unknown() to > > be a rather useful debugging aid. And I can promise you that I'll use NV > > to debug my own crap changes! > > > > Any particular reason against just using reset_unknown()? > > Because debugging NV itself is hell when all you have is a model! Blech! > As we were trying to debug the early code base, we really wanted to > make it easy to run tiny guests without much setup, and work out of > the box. That's how this sort of changes came about. > > In any case, something like this the hack below works as well (I just > booted an L1 and a couple of L2s with it, and nothing caught fire). LGTM, mind squashing it into the previous patch? -- Thanks, Oliver > M. > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 924afc40ab8b..c1016a35a996 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -924,16 +924,6 @@ static void reset_mpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > vcpu_write_sys_reg(vcpu, compute_reset_mpidr(vcpu), MPIDR_EL1); > } > > -static void reset_vmpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > -{ > - vcpu_write_sys_reg(vcpu, compute_reset_mpidr(vcpu), VMPIDR_EL2); > -} > - > -static void reset_vpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > -{ > - vcpu_write_sys_reg(vcpu, read_cpuid_id(), VPIDR_EL2); > -} > - > static unsigned int pmu_visibility(const struct kvm_vcpu *vcpu, > const struct sys_reg_desc *r) > { > @@ -2678,8 +2668,8 @@ static const struct sys_reg_desc sys_reg_descs[] = { > { PMU_SYS_REG(SYS_PMCCFILTR_EL0), .access = access_pmu_evtyper, > .reset = reset_val, .reg = PMCCFILTR_EL0, .val = 0 }, > > - EL2_REG(VPIDR_EL2, access_rw, reset_vpidr, 0), > - EL2_REG(VMPIDR_EL2, access_rw, reset_vmpidr, 0), > + EL2_REG(VPIDR_EL2, access_rw, reset_unknown, 0), > + EL2_REG(VMPIDR_EL2, access_rw, reset_unknown, 0), > EL2_REG(SCTLR_EL2, access_rw, reset_val, SCTLR_EL2_RES1), > EL2_REG(ACTLR_EL2, access_rw, reset_val, 0), > EL2_REG(HCR_EL2, access_rw, reset_val, 0), > > -- > Without deviation from the norm, progress is not possible.