From: Maxim Levitsky <mlevitsk@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Joerg Roedel <joro@8bytes.org>
Cc: kvm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/10] KVM: SVM: Add helper to deduplicate code for getting AVIC backing page
Date: Thu, 05 Oct 2023 15:50:15 +0300 [thread overview]
Message-ID: <e1fa222fb8b48d5268a8be85dbb66e91af45e89a.camel@redhat.com> (raw)
In-Reply-To: <20230815213533.548732-5-seanjc@google.com>
У вт, 2023-08-15 у 14:35 -0700, Sean Christopherson пише:
> Add a helper to get the physical address of the AVIC backing page, both
> to deduplicate code and to prepare for getting the address directly from
> apic->regs, at which point it won't be all that obvious that the address
> in question is what SVM calls the AVIC backing page.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/svm/avic.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
> index b8313f2d88fa..954bdb45033b 100644
> --- a/arch/x86/kvm/svm/avic.c
> +++ b/arch/x86/kvm/svm/avic.c
> @@ -241,14 +241,18 @@ int avic_vm_init(struct kvm *kvm)
> return err;
> }
>
> +static phys_addr_t avic_get_backing_page_address(struct vcpu_svm *svm)
> +{
> + return __sme_set(page_to_phys(svm->avic_backing_page));
> +}
> +
> void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb)
> {
> struct kvm_svm *kvm_svm = to_kvm_svm(svm->vcpu.kvm);
> - phys_addr_t bpa = __sme_set(page_to_phys(svm->avic_backing_page));
> phys_addr_t lpa = __sme_set(page_to_phys(kvm_svm->avic_logical_id_table_page));
> phys_addr_t ppa = __sme_set(page_to_phys(kvm_svm->avic_physical_id_table_page));
>
> - vmcb->control.avic_backing_page = bpa;
> + vmcb->control.avic_backing_page = avic_get_backing_page_address(svm);
> vmcb->control.avic_logical_id = lpa;
> vmcb->control.avic_physical_id = ppa;
> vmcb->control.avic_vapic_bar = APIC_DEFAULT_PHYS_BASE;
> @@ -308,7 +312,7 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu)
> if (!entry)
> return -EINVAL;
>
> - new_entry = __sme_set(page_to_phys(svm->avic_backing_page)) |
> + new_entry = avic_get_backing_page_address(svm) |
> AVIC_PHYSICAL_ID_ENTRY_VALID_MASK;
> WRITE_ONCE(*entry, new_entry);
>
> @@ -859,7 +863,7 @@ get_pi_vcpu_info(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
> pr_debug("SVM: %s: use GA mode for irq %u\n", __func__,
> irq.vector);
> *svm = to_svm(vcpu);
> - vcpu_info->pi_desc_addr = __sme_set(page_to_phys((*svm)->avic_backing_page));
> + vcpu_info->pi_desc_addr = avic_get_backing_page_address(*svm);
> vcpu_info->vector = irq.vector;
>
> return 0;
> @@ -917,7 +921,7 @@ int avic_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
> struct amd_iommu_pi_data pi;
>
> /* Try to enable guest_mode in IRTE */
> - pi.base = __sme_set(page_to_phys(svm->avic_backing_page));
> + pi.base = avic_get_backing_page_address(svm);
> pi.ga_tag = AVIC_GATAG(to_kvm_svm(kvm)->avic_vm_id,
> svm->vcpu.vcpu_id);
> pi.is_guest_mode = true;
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2023-10-05 16:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 21:35 [PATCH 00/10] VM: SVM: Honor KVM_MAX_VCPUS when AVIC is enabled Sean Christopherson
2023-08-15 21:35 ` [PATCH 01/10] KVM: SVM: Drop pointless masking of default APIC base when setting V_APIC_BAR Sean Christopherson
2023-10-05 12:49 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 02/10] KVM: SVM: Use AVIC_HPA_MASK when initializing vCPU's Physical ID entry Sean Christopherson
2023-10-05 12:49 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 03/10] KVM: SVM: Drop pointless masking of kernel page pa's with "AVIC's" HPA mask Sean Christopherson
2023-10-05 12:50 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 04/10] KVM: SVM: Add helper to deduplicate code for getting AVIC backing page Sean Christopherson
2023-10-05 12:50 ` Maxim Levitsky [this message]
2023-08-15 21:35 ` [PATCH 05/10] KVM: SVM: Drop vcpu_svm's pointless avic_backing_page field Sean Christopherson
2023-10-05 12:50 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 06/10] iommu/amd: KVM: SVM: Use pi_desc_addr to derive ga_root_ptr Sean Christopherson
2023-09-28 17:29 ` Joao Martins
2023-10-05 12:50 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 07/10] KVM: SVM: Inhibit AVIC if ID is too big instead of rejecting vCPU creation Sean Christopherson
2023-10-05 12:51 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 08/10] KVM: SVM: WARN if KVM attempts to create AVIC backing page with user APIC Sean Christopherson
2023-10-05 12:52 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 09/10] KVM: SVM: Drop redundant check in AVIC code on ID during vCPU creation Sean Christopherson
2023-10-05 12:58 ` Maxim Levitsky
2023-08-15 21:35 ` [PATCH 10/10] KVM: SVM: Rename "avic_physical_id_cache" to "avic_physical_id_entry" Sean Christopherson
2023-10-05 12:59 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1fa222fb8b48d5268a8be85dbb66e91af45e89a.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®