From patchwork Wed Nov 17 06:43:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12692826 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40024C433EF for ; Wed, 17 Nov 2021 06:48:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F349363212 for ; Wed, 17 Nov 2021 06:48:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F349363212 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=bBbQpHH3zjADEvMKMucNYI4CxlXNfsbKaUokseJ2ZqQ=; b=o9CZrcQVQtnIaYw56mvkauSMOK K0xnmopJZDAJXH1lxisi5toHnEYr9hQ4Xzr4E9T6Yty7Hy4hbSZ3F4Z6ou4tPjWxgfKfJBFPXm3W8 yDuqQoX26C3iBZZ9sdJ4xwHxWb/PSTgSIQ7jvZSMMBZjLAxcgJcv6vGG7i8kJnL8FZ4oqFFis83Xm JkLzayPie37M0tQ/4fdOqmSHH2Ufxo8UdjvPu+pI4ew+jkpVe2xnCZBwKgNFIWA8DGOV1VyeX0kOp FfU98SjoiC0pb9b8nQJYROj72kg+bVIQ9KAfR0GLatVykdINT6kBE9kRZKzHlADvitsHEJOzmFHet ZrHzJaZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnEiQ-003XBB-0X; Wed, 17 Nov 2021 06:46:42 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnEiL-003X9m-IX for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 06:46:39 +0000 Received: by mail-pf1-x44a.google.com with SMTP id w7-20020aa78587000000b004a28bb92381so1081100pfn.22 for ; Tue, 16 Nov 2021 22:46:35 -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=N8fXLZvqvLp46Vlb4MzkHW+PGd4Y1uV4+vNk1MNsoX0=; b=elNT4EfICJasbMSr/sYT0V1/WkFPMoqyqLRbGmG7zbzGDFT6A4OQRNMQGgcXR0LaSX oLEu/mbv1y3wwz3gKGrHjlgyRVltbe5BnSEaGEUFHNujVkdVYM7yEnqle/1ENDCe59t4 yfQK7K/JOWgUWTTmlLUj+CgQjQgrgQnltIJ9mc065L65W9UDIAtVBzxY/T9FxKVtGU4Z pPabu4FCY5kW58/Np0jr4Pmd1Hg6LcbQkgOzQJShJfb9aqtddBl85imtFziYKFyKIRWj ArwDotwmWfET5LLJ55ke68oyxkVYzKI0hR/rDvAIfOw37WfDwQ5rBxhavWPRQtst24dk XTrw== 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=N8fXLZvqvLp46Vlb4MzkHW+PGd4Y1uV4+vNk1MNsoX0=; b=REyRh/a1Nu7ROp8KfSb0ImcotRBgICI0daT0jbgOTrraoBjnqzSvTx70zl7rUFLn6S OOS2k20ZbiEpoS89VUcZI5Z479zk56TL96iKCQ/w9H3BESReFKZokVTAW5onqlpMGyrW wFEsIy/t+LSPK3lFIVdlWtNqP7B6p+ptV/YeC0GzOn9+qdLFVn39xEBIcKmCHheYVdq5 UGMJVbNLNXdDq3NIiCUWzD0L+oFvMdNBUtEvx1DqLJe0qqhMdegnCnorXO+xKvkObwAE 1ZU7OcwZ+ctAg2td1xfkEjTaIlvKHkBe1uZRAq2C8h7ppVN1aevXJH3OinZrJHN1eJTn Gd2g== X-Gm-Message-State: AOAM533tnnQTVzUL5hfr2eC+MWPPqH+u+2UX8GmXrwheQiXYvZve8ClT VYxQ6xGGBbr76nxgoh0aYuLB+LqUogw= X-Google-Smtp-Source: ABdhPJwNBUSOEB1JuFJIrJfbR51JUxxZJ1OON4wodu+1NC7Urx/fRiLZJ4etkL1sB/ACUMvvsEJ5yqyqc0k= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a62:15d0:0:b0:4a0:2dd5:ee4e with SMTP id 199-20020a6215d0000000b004a02dd5ee4emr46726718pfv.14.1637131594948; Tue, 16 Nov 2021 22:46:34 -0800 (PST) Date: Tue, 16 Nov 2021 22:43:31 -0800 In-Reply-To: <20211117064359.2362060-1-reijiw@google.com> Message-Id: <20211117064359.2362060-2-reijiw@google.com> Mime-Version: 1.0 References: <20211117064359.2362060-1-reijiw@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [RFC PATCH v3 01/29] KVM: arm64: Add has_reset_once flag for vcpu 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-20211116_224637_657065_3E3C4B35 X-CRM114-Status: GOOD ( 10.69 ) 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 'has_reset_once' flag in kvm_vcpu_arch, which indicates if the vCPU reset has been done once, for later use. Signed-off-by: Reiji Watanabe Reviewed-by: Oliver Upton --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/reset.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 2a5f7f38006f..edbe2cb21947 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -385,6 +385,7 @@ struct kvm_vcpu_arch { u64 last_steal; gpa_t base; } steal; + bool has_reset_once; }; /* Pointer to the vcpu's SVE FFR for sve_{save,load}_state() */ @@ -450,6 +451,7 @@ struct kvm_vcpu_arch { #define vcpu_has_sve(vcpu) (system_supports_sve() && \ ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE)) +#define vcpu_has_reset_once(vcpu) ((vcpu)->arch.has_reset_once) #ifdef CONFIG_ARM64_PTR_AUTH #define vcpu_has_ptrauth(vcpu) \ diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 426bd7fbc3fd..c3a91ab370fa 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -305,6 +305,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) if (loaded) kvm_arch_vcpu_load(vcpu, smp_processor_id()); preempt_enable(); + + if (!ret && !vcpu->arch.has_reset_once) + vcpu->arch.has_reset_once = true; + return ret; }