Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp536017iob; Wed, 4 May 2022 02:26:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2vl1FQOYfLkkJItnG4bDsxNXNXyRsweVnRy0rtPXT9/us4mC1t3BUwainrnNCV+FI5Kyk X-Received: by 2002:a17:907:94d2:b0:6f4:b5f9:6f3a with SMTP id dn18-20020a17090794d200b006f4b5f96f3amr2757630ejc.313.1651656402674; Wed, 04 May 2022 02:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651656402; cv=none; d=google.com; s=arc-20160816; b=brTJR1uTfKscg1YoQHqAgfh0KOQqbtPtJfNxI4nLYDB26YAmZeaie9eK450g1UpIDk 1ggmYllCjdO87xRK/wFHccmTs3SiZEVyFrY8zOtDbrmP6bgpLky3tlFd6GzhOmkavYNh OHcHHD/8dcIlnoXRI0BU3CkObQufwTqCavQj4JiGTooQiAnJF5kGKfMrVtkMjqS2Jpsi 26OdLUFAne+HOTrl85ov8r4TU+oftnAR19UHeReYG7X458Cd2Htu+7GoN0jBq8eN5iYM l27YSw/uyGDZ1TR8LwAeUdhPuBLkYTPlzsuFwkhoiDwcqgKMbPFMaHwwwVDXRpa42nSj WBnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=6maep/AV6x/UR2I9bnVT8WrPU4v6xTaQlTwkFBlftD8=; b=qTa7avtoigsiQAPcm4dsIa4ZGDQcX6/6KvWJaxGcXdpfq0KsVeaWdZy4q95qcl+jWN e0D9y1/R/ad3m+zdfxq4p7W2kRDOBMekDFxSEinCtxMu8jRqrKrF/jumgtuOgxr+pqD/ bNlGzC4sdb2c2oNEbXFH081TQFq3FQbm61oeAYAgbL3jUEE+ArK/1jfY5Wteh+w37cCn eHz4UQFdiaIUom/qgOIYHz+lyFLd/iwUuDpLUfLpeMYs/NgvTzBdUtWVfwFHJbnfLyKL uiGoK5p97Ay0zW+V1h1uGSp41GRzCti377qDMR9a4y9G3nwgbedeMjIdSJemOhkT8jwp r5GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hi6mCfou; 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 tc3-20020a1709078d0300b006f4a597941csi2067079ejc.118.2022.05.04.02.26.19; Wed, 04 May 2022 02:26:42 -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=Hi6mCfou; 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 S240129AbiECRRs (ORCPT + 99 others); Tue, 3 May 2022 13:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240119AbiECRRo (ORCPT ); Tue, 3 May 2022 13:17:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A572C1CFF0; Tue, 3 May 2022 10:14:11 -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 61A28B81F74; Tue, 3 May 2022 17:14:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE9B8C385A9; Tue, 3 May 2022 17:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651598049; bh=AplqjMJygV5N2GJ3+bH6/snyHg1GxYj0Pi04o+s5Et0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Hi6mCfouyVmjZxSVbORS/GhkRPnI8onFUPKaZL32RKjhslEyhjFCcgfoHKxl3MFD2 mp0RhJ/mF5wujJ+csCdONmvxh/iqPpooUX+SqLoMtumsgGEMUxsKDYu98tdyzxgBAy NitGG9dXGgMCuq61CfZaA3pbu0G6Gx6hB5Z6SnIJtDnE/o6YzJrzTunYhIRdZieTTy a1A+R9HMMO5jTOeiDYLmWEOSamfz1rm/PZRd19SrejUhKGJY42IIWuV2fHVXV83LUP 2HbvLHn/rN/rrGo6gwV8mwrAaG+pj4VUPcc9E8aWlVLfsT/BggH0NLG8kyLm8Sj6CX on/ZMB7FSaQPw== 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 1nlw6A-008hld-7y; Tue, 03 May 2022 18:14:06 +0100 Date: Tue, 03 May 2022 18:14:06 +0100 Message-ID: <87a6by8roh.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, Gavin Shan Subject: Re: [PATCH v7 6/9] Docs: KVM: Add doc for the bitmap firmware registers In-Reply-To: <20220502233853.1233742-7-rananta@google.com> References: <20220502233853.1233742-1-rananta@google.com> <20220502233853.1233742-7-rananta@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") Content-Type: text/plain; charset=US-ASCII 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, gshan@redhat.com 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.7 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 00:38:50 +0100, Raghavendra Rao Ananta wrote: > > Add the documentation for the bitmap firmware registers in > hypercalls.rst and api.rst. This includes the details for > KVM_REG_ARM_STD_BMAP, KVM_REG_ARM_STD_HYP_BMAP, and > KVM_REG_ARM_VENDOR_HYP_BMAP registers. > > Since the document is growing to carry other hypercall related > information, make necessary adjustments to present the document > in a generic sense, rather than being PSCI focused. > > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Gavin Shan > --- > Documentation/virt/kvm/api.rst | 16 ++++ > Documentation/virt/kvm/arm/hypercalls.rst | 94 ++++++++++++++++++----- > 2 files changed, 92 insertions(+), 18 deletions(-) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 4a900cdbc62e..8ae638be79fd 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -2542,6 +2542,22 @@ arm64 firmware pseudo-registers have the following bit pattern:: > > 0x6030 0000 0014 > > +arm64 bitmap feature firmware pseudo-registers have the following bit pattern:: > + > + 0x6030 0000 0016 > + > +The bitmap feature firmware registers exposes the hypercall services that are > +available for userspace to configure. The set bits corresponds to the services > +that are available for the guests to access. By default, KVM sets all the > +supported bits during VM initialization. The userspace can discover the > +available services via KVM_GET_ONE_REG, and write back the bitmap corresponding > +to the features that it wishes guests to see via KVM_SET_ONE_REG. > + > +Note: These registers are immutable once any of the vCPUs of the VM has run at > +least once. A KVM_SET_ONE_REG in such a scenario will return a -EBUSY to userspace. > + The placement is odd, as SVE uses ID 0x0015, and is *after* this. > +(See Documentation/virt/kvm/arm/hypercalls.rst for more details.) > + > arm64 SVE registers have the following bit patterns:: > > 0x6080 0000 0015 00 Zn bits[2048*slice + 2047 : 2048*slice] > diff --git a/Documentation/virt/kvm/arm/hypercalls.rst b/Documentation/virt/kvm/arm/hypercalls.rst > index d52c2e83b5b8..383ca766cf36 100644 > --- a/Documentation/virt/kvm/arm/hypercalls.rst > +++ b/Documentation/virt/kvm/arm/hypercalls.rst > @@ -1,32 +1,32 @@ > .. SPDX-License-Identifier: GPL-2.0 > > -========================================= > -Power State Coordination Interface (PSCI) > -========================================= > +======================= > +ARM Hypercall Interface > +======================= > > -KVM implements the PSCI (Power State Coordination Interface) > -specification in order to provide services such as CPU on/off, reset > -and power-off to the guest. > +KVM handles the hypercall services as requested by the guests. New hypercall > +services are regularly made available by the ARM specification or by KVM (as > +vendor services) if they make sense from a virtualization point of view. > > -The PSCI specification is regularly updated to provide new features, > -and KVM implements these updates if they make sense from a virtualization > -point of view. > - > -This means that a guest booted on two different versions of KVM can > -observe two different "firmware" revisions. This could cause issues if > -a given guest is tied to a particular PSCI revision (unlikely), or if > -a migration causes a different PSCI version to be exposed out of the > -blue to an unsuspecting guest. > +This means that a guest booted on two different versions of KVM can observe > +two different "firmware" revisions. This could cause issues if a given guest > +is tied to a particular version of a hypercall service, or if a migration > +causes a different version to be exposed out of the blue to an unsuspecting > +guest. > > In order to remedy this situation, KVM exposes a set of "firmware > pseudo-registers" that can be manipulated using the GET/SET_ONE_REG > interface. These registers can be saved/restored by userspace, and set > -to a convenient value if required. > +to a convenient value as required. > > -The following register is defined: > +The following registers are defined: > > * KVM_REG_ARM_PSCI_VERSION: > > + KVM implements the PSCI (Power State Coordination Interface) > + specification in order to provide services such as CPU on/off, reset > + and power-off to the guest. > + > - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set > (and thus has already been initialized) > - Returns the current PSCI version on GET_ONE_REG (defaulting to the > @@ -74,4 +74,62 @@ The following register is defined: > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED: > The workaround is always active on this vCPU or it is not needed. > > -.. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf > + > +Bitmap Feature Firmware Registers > +--------------------------------- > + > +Contrary to the above registers, the following registers exposes the hypercall > +services in the form of a feature-bitmap to the userspace. This bitmap is > +translated to the services that are available to the guest. There is a register > +defined per service call owner and can be accessed via GET/SET_ONE_REG interface. > + > +By default, these registers are set with the upper limit of the features that > +are supported. This way userspace can discover all the electable hypercall services > +via GET_ONE_REG. The user-space can write-back the desired bitmap back via > +SET_ONE_REG. The features for the registers that are untouched, probably because > +userspace isn't aware of them, will be exposed as is to the guest. > + > +Note that KVM would't allow the userspace to configure the registers anymore once > +any of the vCPUs has run at least once. Instead, it will return a -EBUSY. > + Formatting is a bit off. We try to stay within the 80 cols format for text documents such as this. > +The psuedo-firmware bitmap register are as follows: Typo. > + > +* KVM_REG_ARM_STD_BMAP: > + Controls the bitmap of the ARM Standard Secure Service Calls. > + > + The following bits are accepted: > + > + Bit-0: KVM_REG_ARM_STD_BIT_TRNG_V1_0: > + The bit represents the services offered under v1.0 of ARM True Random > + Number Generator (TRNG) specification, ARM DEN0098. > + > +* KVM_REG_ARM_STD_HYP_BMAP: > + Controls the bitmap of the ARM Standard Hypervisor Service Calls. > + > + The following bits are accepted: > + > + Bit-0: KVM_REG_ARM_STD_HYP_BIT_PV_TIME: > + The bit represents the Paravirtualized Time service as represented by > + ARM DEN0057A. > + > +* KVM_REG_ARM_VENDOR_HYP_BMAP: > + Controls the bitmap of the Vendor specific Hypervisor Service Calls. > + > + The following bits are accepted: > + > + Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT > + The bit represents the ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID > + and ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID function-ids. > + > + Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_PTP: > + The bit represents the Precision Time Protocol KVM service. > + > +Errors: > + > + ======= ============================================================= > + -ENOENT Unknown register accessed. > + -EBUSY Attempt a 'write' to the register after the VM has started. > + -EINVAL Invalid bitmap written to the register. > + ======= ============================================================= > + > +.. [1] https://developer.arm.com/-/media/developer/pdf/ARM_DEN_0070A_Firmware_interfaces_for_mitigating_CVE-2017-5715.pdf > \ No newline at end of file > -- > 2.36.0.464.gb9c8b46e94-goog > > Thanks, M. -- Without deviation from the norm, progress is not possible.