Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1818586pxm; Thu, 24 Feb 2022 09:54:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNYaTcMiElsVSHSCByJgBMrlJbyuf6PO6hf/SvstWBhCxaeXRaA6325L3st+esgcaACFla X-Received: by 2002:a17:90a:6c66:b0:1bc:52a2:18e8 with SMTP id x93-20020a17090a6c6600b001bc52a218e8mr3958211pjj.180.1645725273970; Thu, 24 Feb 2022 09:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645725273; cv=none; d=google.com; s=arc-20160816; b=GRvxaQMbik1vfj/FgRzxKMIspQ2Xr7J8z2MggGXt7+9gi7WIbtZC3Q18/IePYA5ITU 56xBq1m9PSDquZVIIo0R7Nic0l2W78zjM9Rs1R+24Mr4HEd2omaAc44lKvamNiMHK1TU n/t62pekHuTPGoYNNeiczQ0Kqh6O5YJzWuWLAjj6hblVQx8Fq+tHN2zar6jm1rVZw2Nr 1AOS4RZA0nBj0XFwQWlxXu7DunVYAkGU2P1RpFX8IdueFq+zi1pMECkNAvYnHGcMXVJE zvmlL0tXNUHqVjZ40LcOVim493FjSyJu+RMfAWtB8/0zsy9IuiIAi0FwGCHwKQENBLZR lL5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=OsZB1WQ6lcTDQc8TII8Z2w2H891AEk6o7uXrnU60Sz4=; b=q/gTB5+EMPiHSCcw5S5sWOwCaSCiYjY5XcA4DJiCd89N34G0aY9920XqvzoK49Ufk7 XphM9H0MyGXiVEZAfTGKaylaa7EGsrBG0Y7NaFj6TjmLMdXlfaraT1hvRlNezNsiGmZz 2fSpRoHieOnhrGC0h8GCul2cD4uXpI6wukkyJ6xz0OgqkSEfqPteSFlK+ZM875dBJ0FM Vqgqlcs/61y1jFQuJ/KXJa38ye4qUF/krALZPHALM4ck0SC6dI6mEcXbKmrW82jvxGHV zoRIQooS27bhDc3uFa6SJ6FQwMx5uO9vQapX5ARBQR2uyctCeurTXarDbhbTByxfgKna +L+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="n/F4ja1w"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s29si2599233pgo.648.2022.02.24.09.54.17; Thu, 24 Feb 2022 09:54:33 -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; dkim=pass header.i=@google.com header.s=20210112 header.b="n/F4ja1w"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbiBXR1D (ORCPT + 99 others); Thu, 24 Feb 2022 12:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbiBXR0p (ORCPT ); Thu, 24 Feb 2022 12:26:45 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED0DF278C9B for ; Thu, 24 Feb 2022 09:26:15 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id f4-20020a17090ac28400b001bc40aa09fbso3918521pjt.6 for ; Thu, 24 Feb 2022 09:26:15 -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=OsZB1WQ6lcTDQc8TII8Z2w2H891AEk6o7uXrnU60Sz4=; b=n/F4ja1wwLJBW/ijXvomC0vFaa1Gbh0XTIQ72X/rtTtlaWrnWJVjVDVQnw0Chugj0j s8eGLxLruJTXlJ3udhRPkErT9dlaCCvq+4Pc/4AyP6fslw5wApjjMzXxR5JolWEo3Uhn /xF8xB+oMyZoF8zM+m9Y3UAvlg9Q5fezULZ3Z37nGxzJzBcGlg2zHbru5rcSqCNNtg96 iSGxIhYOowJ4KOjg8isnidQLFfTqDemO76gaoctt3D7t2fR4oP7+MifAHi8KKPk6R9uU ke+J+3OxaxPspS1mFy6prNU6GZzF3ophbL5sU3A7T9zPgk19vFCo7IozP+KWOWWnuJ5v YFJQ== 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=OsZB1WQ6lcTDQc8TII8Z2w2H891AEk6o7uXrnU60Sz4=; b=t6mnZ+Yuj2K3o8LOIaH24qbcDR0JUu/X0cVTNBG30VU1e96NvCOPpfzNY/RpWwc7eB DuE4wt3tdSy3dR8gqp4qORDfH77xiUul6ix7n/XCOKRMWWmlFOZAfBiZ6UYTjMqox1uy IXBi+Egnd6Z7ilGYaoex2obMPdbkWd4YMSYPdWpCt4PHWG9QiM7RqfnK5OZrlO/cvSRb RC2sdYCA2RYAGB7w4Ch+Z42s9Hmd2pOpZKm3Bi23AQuI9y28VkrJCz0xQzLpz3n1TxFL 25DrPtzrm3zPN86pnkUM/7GmsCDClW+d6CFYLSUWjOmZ/TeKd5HT3WNv63lP6xsop2JN zx6w== X-Gm-Message-State: AOAM530o8UITq0MDyUUgFgSJRBwp2oYpPfM+zjXzdTRDgPlrJUuTYWOW pka6iFQFwOBZyvUc765DEKxMOAYlEum0 X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:90a:2c0c:b0:1b9:fa47:1caf with SMTP id m12-20020a17090a2c0c00b001b9fa471cafmr3880202pjd.34.1645723575490; Thu, 24 Feb 2022 09:26:15 -0800 (PST) Date: Thu, 24 Feb 2022 17:25:50 +0000 In-Reply-To: <20220224172559.4170192-1-rananta@google.com> Message-Id: <20220224172559.4170192-5-rananta@google.com> Mime-Version: 1.0 References: <20220224172559.4170192-1-rananta@google.com> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog Subject: [PATCH v4 04/13] KVM: arm64: Capture VM's first run From: Raghavendra Rao Ananta To: Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 Capture the first run of the KVM VM, which is basically the first KVM_RUN issued for any vCPU. This state of the VM is helpful in the upcoming patches to prevent user-space from configuring certain VM features, such as the feature bitmap exposed by the psuedo-firmware registers, after the VM has started running. Signed-off-by: Raghavendra Rao Ananta --- arch/arm64/include/asm/kvm_host.h | 9 +++++++++ arch/arm64/kvm/arm.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 657733554d98..e823571e50cc 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -139,6 +139,9 @@ struct kvm_arch { /* Register scoping enabled for KVM registers */ bool reg_scope_enabled; + + /* Capture first run of the VM */ + bool has_run_once; }; struct kvm_vcpu_fault_info { @@ -796,6 +799,12 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu); int kvm_trng_call(struct kvm_vcpu *vcpu); int kvm_arm_reg_id_encode_scope(struct kvm_vcpu *vcpu, u64 *reg_id); void kvm_arm_reg_id_clear_scope(struct kvm_vcpu *vcpu, u64 *reg_id); + +static inline bool kvm_arm_vm_has_run_once(struct kvm_arch *kvm_arch) +{ + return kvm_arch->has_run_once; +} + #ifdef CONFIG_KVM extern phys_addr_t hyp_mem_base; extern phys_addr_t hyp_mem_size; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 107977c82c6c..f61cd8d57eae 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -635,6 +635,8 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) if (kvm_vm_is_protected(kvm)) kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu); + kvm->arch.has_run_once = true; + return ret; } -- 2.35.1.473.g83b2b277ed-goog