From patchwork Fri Jan 27 11:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 49282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp787481wrn; Fri, 27 Jan 2023 03:44:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXs99tNgWUA1bsM7yp1ybqQzZaleIoG7yqpdgrL4IRqVkM8CkbRj9VFC2qzxGUL7cDq4igez X-Received: by 2002:a05:6a20:a682:b0:ad:5747:9f6e with SMTP id ba2-20020a056a20a68200b000ad57479f6emr38953925pzb.39.1674819876383; Fri, 27 Jan 2023 03:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674819876; cv=none; d=google.com; s=arc-20160816; b=OBZunOespFLpNqYK8lsZPvlsvOd8IcPCpms8W8ZHkqiNWSXpX3RVTlduR0WM4AhKCC ZYIRw5XuDnBVtTkm1Ll8dc0X3lEvF1MUogttvU3HTVtW7Ue/DQHI9e+ngnwTHDhwv3+w FkArYyWt/xbKWRfBF/BTzFMbE810p+X2UFs8hHLPpD9p6mguZ4vKbbSCKNmcAJIOYcGs BpOYxWe0lwAqh63t1MqYL4vQCZftCqcKJ6AdH7qBeIl1I1w0HQ10GvRysaVx1iECGTDR cbiF2l8WlvDm3MIj9ogvi5DaLDLUh3VOW/K4GNuxr0pCLY5bO+uweth9Vcj1fHnihi+F QCIA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/1o+bRjjE4XQGyRBsNTobl1l+DnZQ4gwHzvp83AEnVs=; b=ldzoq+GpIx9AFXX65ou1oWiPYLPYAE2af6/1+A39xKJBk++hoIW9Rlt5ZgzfLRibbB kaewiJc7ThZvavTsnbzcGX5sjbxd0MJl6XFgqopoC0AcHwkI4WOzOLacePJP8tli4VDO JH2ajpjhC5BfVbEAVndEWYibAMh/Be2ix9ibLLg6DKDp01dkZvopGiedtDWLGgnRU5eN 5T3yhmebKSxVcNLDDkVRDbfllT6dR9qvDeLo6wzaRVeA7wBV/tlkslQLRM+OPuIZLASZ CZIERtaRdoldxBKtKgql4MFNU/LxYB4zXEVKICge0N7r6eZ2nF7vYxTyZR8E0vmegNEa G5fw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a637a45000000b004d2f5bb933dsi4087362pgn.76.2023.01.27.03.44.23; Fri, 27 Jan 2023 03:44:36 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbjA0Lla (ORCPT + 99 others); Fri, 27 Jan 2023 06:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233864AbjA0LlK (ORCPT ); Fri, 27 Jan 2023 06:41:10 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA711196B1; Fri, 27 Jan 2023 03:40:42 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8928E169C; Fri, 27 Jan 2023 03:40:56 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0A2453F64C; Fri, 27 Jan 2023 03:40:11 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 09/31] arm64: Add --realm command line option Date: Fri, 27 Jan 2023 11:39:10 +0000 Message-Id: <20230127113932.166089-10-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756175926688206228?= X-GMAIL-MSGID: =?utf-8?q?1756175926688206228?= From: Alexandru Elisei Add the --realm command line option which causes kvmtool to exit with an error if specified, but which will be enabled once realms are fully supported by kvmtool. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 5 ++++- arm/aarch64/kvm.c | 20 ++++++++++++++++++-- arm/include/arm-common/kvm-config-arch.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index b055fef4..d2df850a 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -21,7 +21,10 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); OPT_BOOLEAN('\0', "no-pvtime", &(cfg)->no_pvtime, "Disable" \ " stolen time"), \ OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ - "Disable SVE"), + "Disable SVE"), \ + OPT_BOOLEAN('\0', "realm", &(cfg)->is_realm, \ + "Create VM running in a realm using Arm RME"), + #include "arm-common/kvm-config-arch.h" #endif /* KVM__KVM_CONFIG_ARCH_H */ diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 5a53badb..25be2f2d 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -38,9 +38,8 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset) return 0; } -void kvm__arch_validate_cfg(struct kvm *kvm) +static void validate_mem_cfg(struct kvm *kvm) { - if (kvm->cfg.ram_addr < ARM_MEMORY_AREA) { die("RAM address is below the I/O region ending at %luGB", ARM_MEMORY_AREA >> 30); @@ -52,6 +51,23 @@ void kvm__arch_validate_cfg(struct kvm *kvm) } } +static void validate_realm_cfg(struct kvm *kvm) +{ + if (!kvm->cfg.arch.is_realm) + return; + + if (kvm->cfg.arch.aarch32_guest) + die("Realms supported only for 64bit guests"); + + die("Realms not supported"); +} + +void kvm__arch_validate_cfg(struct kvm *kvm) +{ + validate_mem_cfg(kvm); + validate_realm_cfg(kvm); +} + u64 kvm__arch_default_ram_address(void) { return ARM_MEMORY_AREA; diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 6599305b..5eb791da 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -11,6 +11,7 @@ struct kvm_config_arch { bool aarch32_guest; bool has_pmuv3; bool mte_disabled; + bool is_realm; u64 kaslr_seed; enum irqchip_type irqchip; u64 fw_addr;