Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3464933iob; Tue, 17 May 2022 00:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyW2Vq7V0+5Hu+p5snVf9PX1O7zepvAufWgI5yyjR58SeJ+evrGuYSNDow6Fg8GlFyglh9 X-Received: by 2002:a17:90a:930b:b0:1d5:684b:8e13 with SMTP id p11-20020a17090a930b00b001d5684b8e13mr23505215pjo.153.1652770961677; Tue, 17 May 2022 00:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652770961; cv=none; d=google.com; s=arc-20160816; b=BJsbwkdV5Noh4J5GVdZH+1t34/C5m8XrLfUJYh2fFvigmU7XwPCWZEEyfMRQcdisuI FYy+mOdlhyEKtY1HZHuYhjQCWrhpeFuM769jREIEz+ZxR3qGFGuPQqJoaka7CEDYeqIq UvDDxLax4m1r11fCibm2HVIAng9wv6ssr6oJKhAoOKNNPuHUx8zDRXVvvM6w5eGzDKO+ s3ZL0ZsHvoJoHB8kYQYGoVYtm4LQ3EaFoxlmUugcyDVbHg4D28lCtY7nLLdhDmD9JcrC AvTRw4WphWTe6DQ8MLiIbuHxWkadgu73JMBit81HfXw8BVvn1JHTsGPXk4Neu3oCc+GQ Re3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=w/dzXT5Ex4amGheRsZ5P6QrWOx2Hxh8LClvl7Ba5awE=; b=NY9mnytFHMtHGn21BgTjzpvkzgVdggpv+XQvykK/AnvrE4Y8SMsr3lMPntzxUBvgHd WDJC+jekt/3S1i00aJM1WfO2zjnYoxV9aFzm+ZKxYUbUVqPxFPVI99cGYAkdjr/stFuT FYxO4IHuerYT3M8zcXeBrsMwQGQt6BUlHnVX1q1Oti8tcq+dCPzyMsSvE+MbncISct5Z QDU1cha4+mvaMa2sP5Uc9/bBesSOLyyMBnCUggqOqPIoGYD/2/9ItnDDYHauAWBo7EHN hih8AMfmU2tMkHRAKo7uPKTN8CqoATMKq+B5hhZ8B+sAIg+nEHT0He400jOeoVreUxU5 /F2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hQ3raqWS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a63e051000000b003c380b38a80si15483388pgj.307.2022.05.17.00.02.29; Tue, 17 May 2022 00:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hQ3raqWS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343817AbiEPQoh (ORCPT + 99 others); Mon, 16 May 2022 12:44:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244534AbiEPQog (ORCPT ); Mon, 16 May 2022 12:44:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78763C4B1; Mon, 16 May 2022 09:44:34 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 603BAB81263; Mon, 16 May 2022 16:44:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4206C385AA; Mon, 16 May 2022 16:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652719472; bh=CYEvraFOukMkXu6WJZExhFsNqffzBStRQaubVucF2VE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hQ3raqWSwFK4Im/gQu5BrQ4j5EyxbLqHUz+Thyw+Air6BDVAOJuI4kc6nzyOZ25OU b1AY5WRVxEfX6D07dcOBR9dytT7129POMhLMkPhRECoHIpow/eHniKQmN8v6TxqUJV tJixyVk71SO7PdcAHVfTeXZiyZVkkd5CwEajyv+QDZqiavEnxLHiwL/2xdBqhdWSmN 4A3s5b1Svfd80b2zJy//vKyhJqZOMOaPIwhpcG+FpUJYzDEkcVA7zm4loAzpNzjGFT Dleu4A7zeI1r9OS5GBL1rbamw5P5i4i0d7rnznuEpn/KsRQ8jpMJhqvFRfO1ZSnsZQ 1f1tFAW7qheOA== 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 1nqdpc-00Bfyr-Tm; Mon, 16 May 2022 17:44:29 +0100 Date: Mon, 16 May 2022 17:44:28 +0100 Message-ID: <87ilq55swj.wl-maz@kernel.org> From: Marc Zyngier To: Raghavendra Rao Ananta Cc: Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v7 0/9] KVM: arm64: Add support for hypercall services selection In-Reply-To: References: <20220502233853.1233742-1-rananta@google.com> <878rri8r78.wl-maz@kernel.org> <878rriicez.wl-maz@kernel.org> 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") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: rananta@google.com, drjones@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, pbonzini@redhat.com, catalin.marinas@arm.com, will@kernel.org, pshier@google.com, ricarkol@google.com, oupton@google.com, reijiw@google.com, jingzhangos@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 03 May 2022 22:09:29 +0100, Raghavendra Rao Ananta wrote: >=20 > On Tue, May 3, 2022 at 1:33 PM Marc Zyngier wrote: > > > > On Tue, 03 May 2022 19:49:13 +0100, > > Raghavendra Rao Ananta wrote: > > > > > > Hi Marc, > > > > > > On Tue, May 3, 2022 at 10:24 AM Marc Zyngier wrote: > > > > > > > > On Tue, 03 May 2022 00:38:44 +0100, > > > > Raghavendra Rao Ananta wrote: > > > > > > > > > > Hello, > > > > > > > > > > Continuing the discussion from [1], the series tries to add suppo= rt > > > > > for the userspace to elect the hypercall services that it wishes > > > > > to expose to the guest, rather than the guest discovering them > > > > > unconditionally. The idea employed by the series was taken from > > > > > [1] as suggested by Marc Z. > > > > > > > > As it took some time to get there, and that there was still a bunch= of > > > > things to address, I've taken the liberty to apply my own fixes to = the > > > > series. > > > > > > > > Please have a look at [1], and let me know if you're OK with the > > > > result. If you are, I'll merge the series for 5.19. > > > > > > > > Thanks, > > > > > > > > M. > > > > > > > Thank you for speeding up the process; appreciate it. However, the > > > series's selftest patches have a dependency on Oliver's > > > PSCI_SYSTEM_SUSPEND's selftest patches [1][2]. Can we pull them in > > > too? > > > > Urgh... I guess this is the time to set some ground rules: > > > > - Please don't introduce dependencies between series, that's > > unmanageable. I really need to see each series independently, and if > > there is a merge conflict, that's my job to fix (and I don't really > > mind). > > > > - If there is a dependency between series, please post a version of > > the required patches as a prefix to your series, assuming this > > prefix is itself standalone. If it isn't, then something really is > > wrong, and the series should be resplit. > > > > - You also should be basing your series on an *official* tag from > > Linus' tree (preferably -rc1, -rc2 or -rc3), and not something > > random like any odd commit from the KVM tree (I had conflicts while > > applying this on -rc3, probably due to the non-advertised dependency > > on Oliver's series). > > > Thanks for picking the dependency patches. I'll keep these mind the > next time I push changes. >=20 > > > > > > aarch64/hypercalls.c: In function =E2=80=98guest_test_hvc=E2=80=99: > > > aarch64/hypercalls.c:95:30: error: storage size of =E2=80=98res=E2=80= =99 isn=E2=80=99t known > > > 95 | struct arm_smccc_res res; > > > | ^~~ > > > aarch64/hypercalls.c:103:17: warning: implicit declaration of function > > > =E2=80=98smccc_hvc=E2=80=99 [-Wimplicit-function-declaration] > > > 103 | smccc_hvc(hc_info->func_id, hc_info->arg1, 0, > > > 0, 0, 0, 0, 0, &res); > > > | ^~~~~~~~~ > > > > > > > I've picked the two patches, which means they will most likely appear > > twice in the history. In the future, please reach out so that we can > > organise this better. > > > > > Also, just a couple of readability nits in the fixed version: > > > > > > 1. Patch-2/9, hypercall.c:kvm_hvc_call_default_allowed(), in the > > > 'default' case, do you think we should probably add a small comment > > > that mentions we are checking for func_id in the PSCI range? > > > > Dumped a one-liner there. > > > > > 2. Patch-2/9, arm_hypercall.h, clear all the macros in this patch > > > itself instead of doing it in increments (unless there's some reason > > > that I'm missing)? > > > > Ah, rebasing leftovers, now gone. > > > > I've pushed an updated branch again, please have a look. > > > Thanks for addressing these. The series looks good now. Except it doesn't. I introduced a bug by overly simplifying kvm_arm_set_fw_reg_bmap(), as we have to allow userspace writing the *same* value. As it turns out, QEMU restores all the registers on each reboot. Which as the vcpus have all run. This in turns triggers another issue in QEMU, which instead of taking the hint ans stopping there, sends all the vcpus into the guest in one go with random states... Crap happens. I'll wear a brown paper bag for the rest of the day and add the following patch to the branch. Thanks, M. =46rom 528ada2811ba0bb2b2db5bf0f829b48c50f3c13c Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Mon, 16 May 2022 17:32:54 +0100 Subject: [PATCH] KVM: arm64: Fix hypercall bitmap writeback when vcpus have already run We generally want to disallow hypercall bitmaps being changed once vcpus have already run. But we must allow the write if the written value is unchanged so that userspace can rewrite the register file on reboot, for example. Without this, a QEMU-based VM will fail to reboot correctly. The original code was correct, and it is me that introduced the regression. Fixes: 05714cab7d63 ("KVM: arm64: Setup a framework for hypercall bitmap fi= rmware registers") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hypercalls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index ccbd3cefb91a..c9f401fa01a9 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -379,7 +379,8 @@ static int kvm_arm_set_fw_reg_bmap(struct kvm_vcpu *vcp= u, u64 reg_id, u64 val) =20 mutex_lock(&kvm->lock); =20 - if (test_bit(KVM_ARCH_FLAG_HAS_RAN_ONCE, &kvm->arch.flags)) { + if (test_bit(KVM_ARCH_FLAG_HAS_RAN_ONCE, &kvm->arch.flags) && + val !=3D *fw_reg_bmap) { ret =3D -EBUSY; goto out; } --=20 2.34.1 --=20 Without deviation from the norm, progress is not possible.