From patchwork Thu Jan 6 04:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12705118 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 D7C5CC433EF for ; Thu, 6 Jan 2022 04:36:56 +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=hizVHnjBJZ192iIJbVXLZYJtNobBJGi+IdWimFtFZYE=; b=LeJ6jdKJdA71P7jxugMx/5Aa0e AK9k7i1vXdY0sf3hkIIEJyKkQROpkN0gpOVU73tY/DN4lMgxhQEpaWe926ehiSI3+EXUVcb0QDoI6 99Z6Cm8ToGmLWFUnorb5Ud1uK43tcqbnHi4cs2cDFA7g8hj5aeeu3SYXZVNPJf/amck4ohCU3uSFh X+lR5hwsZRBAdkRFG0Mqw4alRx21t6KzbJsv22BzQk+DGaTB8ilP0fn5RsuSgEu51uxXng7a6LBYa nvWeTgVrleuw1fIEKv+gOV+oETW3m3+MjCuDRZN6l1dmNA967l7BUACT5HodA2ateHazhxv8bsEkR 8lIxk3BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5KUV-00GUuh-9q; Thu, 06 Jan 2022 04:35:07 +0000 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5KOU-00GRz2-Sf for linux-arm-kernel@lists.infradead.org; Thu, 06 Jan 2022 04:28:56 +0000 Received: by mail-pg1-x54a.google.com with SMTP id c15-20020a63ea0f000000b0033ab6c73a4bso865672pgi.20 for ; Wed, 05 Jan 2022 20:28:54 -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=qsXbUWt4k61IeDMaJ9yBb2pGASPsSAD6bL2wC01t25c=; b=X3r9aCI3viml7Ve7M/vnUEWHj5rEsNNVR6sb7qQzcD8l+h1EFbuICdNFRrf6JnRz0D HhyUCXipJ72usL89WgDrd35ksSuWYF4UeGu6JX7EvzzJ2gbnkaUfxVvPrAcfnuQUR5CO BrXhEsgD4G5nKCZemrjqh8BnoYfw9EZcn2+XSGolSgF4YpW5Pyd3NMq4FC7rnxIpUGPO ptAYwJWAyXeEfXygvuj2jHN9J/6ZsLXnuh7reAuronSnzdQicn1PWyHNTmR62yJzghab iKAmQ95r2rug/zKKw1R6nEFh88SK98Ne0RgxUktyWbpS0m5TryJUKxgXFd0STRu3RD6k YFsg== 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=qsXbUWt4k61IeDMaJ9yBb2pGASPsSAD6bL2wC01t25c=; b=HR/rB5TvGoYYhK2T8yyLVCyf6o5JpaF8y324aQRi9kAAMvR5czfuqh+Hh984W8b1ns J/i+8uKzVRdg5rS2julDDXAuAw42cC+LTi5xVlsim1FTBXqglbXO58X0Hp261EJUPljP 0xHcOMgbdGo23v7EoySLc9avDRr1jPQxiI87eO7IJGQhkrq1tieaWlyB/JWpzvgk0TAw DQ7N7CusoaRI3PfRm/i+/gMx55DikAfebBOpsmOUpBvrOe0u9XMOPnr9Qpxjdg6hiXtC L2gxWsH4NmHBJbl0lXMwdeQVlEakUH/Md0dcK/WCaSQyydYgt8D7L5CZVtGMABuEdsj3 8NdA== X-Gm-Message-State: AOAM530Pn1fuG2DSNHn1qQJMJ4mDqg6P/4Ll7yXZsgGN5by+LeXlbZ1v uf0fNgftf9U0TmDYoHWOrSKA7jB12Nk= X-Google-Smtp-Source: ABdhPJw50t65HXqO3xQ2kp1MCKMxMqyY4SYSE/3YVObavipJJ7gE0Al1VQutdOv3vePKB24kL3IGH5TXOOk= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a17:90b:350b:: with SMTP id ls11mr7818734pjb.97.1641443333689; Wed, 05 Jan 2022 20:28:53 -0800 (PST) Date: Wed, 5 Jan 2022 20:26:57 -0800 In-Reply-To: <20220106042708.2869332-1-reijiw@google.com> Message-Id: <20220106042708.2869332-16-reijiw@google.com> Mime-Version: 1.0 References: <20220106042708.2869332-1-reijiw@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [RFC PATCH v4 15/26] KVM: arm64: Introduce KVM_CAP_ARM_ID_REG_CONFIGURABLE capability From: Reiji Watanabe To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Will Deacon , Andrew Jones , Peng Liang , Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220105_202854_994040_E768746F X-CRM114-Status: GOOD ( 11.78 ) 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 Introduce a new capability KVM_CAP_ARM_ID_REG_CONFIGURABLE to indicate that ID registers are writable by userspace. Signed-off-by: Reiji Watanabe --- Documentation/virt/kvm/api.rst | 12 ++++++++++++ arch/arm64/kvm/arm.c | 1 + include/uapi/linux/kvm.h | 1 + 3 files changed, 14 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index aeeb071c7688..86099a9b0bae 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -2574,6 +2574,10 @@ EINVAL. After the vcpu's SVE configuration is finalized, further attempts to write this register will fail with EPERM. +The arm64 ID registers (where Op0=3, Op1=0, CRn=0, 0<=CRm<8, 0<=Op2<8) +are allowed to set by userspace if KVM_CAP_ARM_ID_REG_CONFIGURABLE is +available. They become immutable after calling KVM_RUN on any of the +vcpus in the guest (modifying values of those registers will fail). MIPS registers are mapped using the lower 32 bits. The upper 16 of that is the register group type: @@ -7484,3 +7488,11 @@ The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace the hypercalls whose corresponding bit is in the argument, and return ENOSYS for the others. + +8.35 KVM_CAP_ARM_ID_REG_CONFIGURABLE +------------------------------------ + +:Architectures: arm64 + +This capability indicates that userspace can modify the ID registers +via KVM_SET_ONE_REG ioctl. diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 16fc2ce32069..876f2777acf2 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -216,6 +216,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_SET_GUEST_DEBUG: case KVM_CAP_VCPU_ATTRIBUTES: case KVM_CAP_PTP_KVM: + case KVM_CAP_ARM_ID_REG_CONFIGURABLE: r = 1; break; case KVM_CAP_SET_GUEST_DEBUG2: diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 1daa45268de2..9697c06a7f5b 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1131,6 +1131,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 #define KVM_CAP_ARM_MTE 205 #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 +#define KVM_CAP_ARM_ID_REG_CONFIGURABLE 207 #ifdef KVM_CAP_IRQ_ROUTING