Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1269946iof; Tue, 7 Jun 2022 02:06:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTu+gXQVEWeKef7c3q1oiXZrpNABrhr013431nuaj7+WmYO4piVDTPHhRmW7/O439KU6vY X-Received: by 2002:a17:907:d1e:b0:6fe:b61d:9098 with SMTP id gn30-20020a1709070d1e00b006feb61d9098mr26303294ejc.15.1654592795305; Tue, 07 Jun 2022 02:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654592795; cv=none; d=google.com; s=arc-20160816; b=vYdHnQBqwtDX7WILfbFwWc0DaMZXIvq8XB3CGSFZlwRI3pIHz4vKvisu1GAcNBtjwo kcO4m5MmXsGxwVm+0pDRxTDGRC6LI+PKU2YZwuU9yhrywbGMul2KWrr/ks0n/pLe98bf aaPtsDOcVzAuCktDwjT4x0mgWQfriVgQnbPo1HV0Uc7rezh0ljikNQU5G+lOtcOplPi5 jSNzBdRJ9hM4/bKUkJZXZruKeQVG7zyjzOSqU1Htlwk5EhsjyoI14bWBxCvrlkwt6uCn B50BaaiOqXfEGruNURDuNXCm/WqgpLt9lDlCzqAneOBmTO/hjZMJCMVHg3izQ+2kOgzv X/3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/Gf/XuQlnrCjV08KAe5I+CdEOdoNW4OlHyRl/hczIyw=; b=Z+5CZw5lbNeY3Uitie/UDeynglDRJDHuyH4sMUDEvDaSM9141NBMRbCPNP64RP9H/r sa651W7q0h/nPZ0KuoPqYlo/QXa2TXEgXSAmTctJB9MxVs89SJzL8J774yiXvNm0U5/U Ze8gPUzxRrA2xkYL2AQOA5kTOeL47aNy9YsOuWyro96OriSUqiMmpMd5CljRska2eag1 +yV8BIUw+FkbspS99Hnh1v2o086yvQhW5hAcVbUrs7yfjCRHqtVqrXnfBhkxdzE1f0jY po6KAWBdjLsN4GFV6d0dURYDFTEqd3cMIcKJJ3X/+LJbudDEX1pDL7g+PnePdVf3/19y qn9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RoJbrLva; 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 q24-20020aa7d458000000b0042de30cf6e5si9954444edr.365.2022.06.07.02.06.08; Tue, 07 Jun 2022 02:06:35 -0700 (PDT) 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=RoJbrLva; 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 S232463AbiFFXFS (ORCPT + 99 others); Mon, 6 Jun 2022 19:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232378AbiFFXFQ (ORCPT ); Mon, 6 Jun 2022 19:05:16 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EE29FEA for ; Mon, 6 Jun 2022 16:05:14 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id l9-20020a056830268900b006054381dd35so11811985otu.4 for ; Mon, 06 Jun 2022 16:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/Gf/XuQlnrCjV08KAe5I+CdEOdoNW4OlHyRl/hczIyw=; b=RoJbrLvaMyL3TNZSGqeRwFOHCQiUF/dZovxTI8CZamCwS9em1FOvAl3lUUycrpi2H/ 33Y8aCRdReJvwgF6IeyGVRFaPU058F+k87WJYU43ROg2DS7Vxx6/67z8oiyNr32rse0H Iv7O+ff16d5RPZytV8XapZFr5Mfi7xnHwBfvzqF4vsDc5YxBptI8SV639vG0WDgPDg1I IY9L9il/m9a53GRo+rpmdLhAELS4NMLtEDh5AFivT1mwSeUEtlNN63U/S8wGRx1PBAYT VGgFC5c7mDLsqkyKFQVSeNYot7KHPQQTCw6ZjvnZ1oPM2imAFudla5sb4Btkn0exBIT8 ATGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/Gf/XuQlnrCjV08KAe5I+CdEOdoNW4OlHyRl/hczIyw=; b=1TAdrmM4PspB5gx8oye3eyUpTkKE/ujXWMgLYtKXTduxAykOUlqj6jlTQu3uZhqg0E +5/OuiEkJDDfPcsIugwWf/WDu6PZjuiH/gyKwvaJMy6Z1ciT2o+ucPX0go7WgeJJ6F5I 6ESFhVk540v9dxYHUsoMHDp9grWPgYZuYBcmUYkOT+UPRNbx46qPiRQM5x/IHwGkxqlr 2nfpiVAGIjdc3cE0O87BCYTsV+IlsI9tqnpPr+8qHVQJJAnOHH6BTSVeOJ5AOqzM2GA5 8lMtTBvtvb+SY5Nf8pYG4Vqnqfee2T6Z1JzJHd2/UqMrN3izWXm7kFwXNttPKbEJh24y 3+8w== X-Gm-Message-State: AOAM5329mFS0cURLAlMgkyP85f2ZAUzpPodLInevwEbPpZQaeWMVbnHQ a8pitjHplEsOgjq/PdvkCmfZYUYuHdIgkEC8OpLubQfPMRQ= X-Received: by 2002:a9d:808:0:b0:60c:37:6fcf with SMTP id 8-20020a9d0808000000b0060c00376fcfmr2158290oty.75.1654556713409; Mon, 06 Jun 2022 16:05:13 -0700 (PDT) MIME-Version: 1.0 References: <20220519102709.24125-1-suravee.suthikulpanit@amd.com> In-Reply-To: <20220519102709.24125-1-suravee.suthikulpanit@amd.com> From: Jim Mattson Date: Mon, 6 Jun 2022 16:05:02 -0700 Message-ID: Subject: Re: [PATCH v6 00/17] Introducing AMD x2AVIC and hybrid-AVIC modes To: Suravee Suthikulpanit Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, mlevitsk@redhat.com, seanjc@google.com, joro@8bytes.org, jon.grimm@amd.com, wei.huang2@amd.com, terry.bowman@amd.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Thu, May 19, 2022 at 3:32 AM Suravee Suthikulpanit wrote: > > Introducing support for AMD x2APIC virtualization. This feature is > indicated by the CPUID Fn8000_000A EDX[14], and it can be activated > by setting bit 31 (enable AVIC) and bit 30 (x2APIC mode) of VMCB > offset 60h. > > With x2AVIC support, the guest local APIC can be fully virtualized in > both xAPIC and x2APIC modes, and the mode can be changed during runtime. > For example, when AVIC is enabled, the hypervisor set VMCB bit 31 > to activate AVIC for each vCPU. Then, it keeps track of each vCPU's > APIC mode, and updates VMCB bit 30 to enable/disable x2APIC > virtualization mode accordingly. > > Besides setting bit VMCB bit 30 and 31, for x2AVIC, kvm_amd driver needs > to disable interception for the x2APIC MSR range to allow AVIC hardware > to virtualize register accesses. > > This series also introduce a partial APIC virtualization (hybrid-AVIC) > mode, where APIC register accesses are trapped (i.e. not virtualized > by hardware), but leverage AVIC doorbell for interrupt injection. > This eliminates need to disable x2APIC in the guest on system without > x2AVIC support. (Note: suggested by Maxim) > > Testing for v5: > * Test partial AVIC mode by launching a VM with x2APIC mode > * Tested booting a Linux VM with x2APIC physical and logical modes upto 512 vCPUs. > * Test the following nested SVM test use cases: > > L0 | L1 | L2 > ---------------------------------- > AVIC | APIC | APIC > AVIC | APIC | x2APIC > hybrid-AVIC | x2APIC | APIC > hybrid-AVIC | x2APIC | x2APIC > x2AVIC | APIC | APIC > x2AVIC | APIC | x2APIC > x2AVIC | x2APIC | APIC > x2AVIC | x2APIC | x2APIC > > Changes from v5: > (https://lore.kernel.org/lkml/20220518162652.100493-1-suravee.suthikulpanit@amd.com/T/#t) > * Re-order patch 16 to 10 > * Patch 11: Update commit message > > Changes from v4: > (https://lore.kernel.org/lkml/20220508023930.12881-5-suravee.suthikulpanit@amd.com/T/) > * Patch 3: Move enum_avic_modes definition to svm.h > * Patch 10: Rename avic_set_x2apic_msr_interception to > svm_set_x2apic_msr_interception and move it to svm.c > to simplify the struct svm_direct_access_msrs declaration. > * Patch 16: New from Maxim > * Patch 17: New from Maxim > > Best Regards, > Suravee > > Maxim Levitsky (2): > KVM: x86: nSVM: always intercept x2apic msrs > KVM: x86: nSVM: optimize svm_set_x2apic_msr_interception > > Suravee Suthikulpanit (15): > x86/cpufeatures: Introduce x2AVIC CPUID bit > KVM: x86: lapic: Rename [GET/SET]_APIC_DEST_FIELD to > [GET/SET]_XAPIC_DEST_FIELD > KVM: SVM: Detect X2APIC virtualization (x2AVIC) support > KVM: SVM: Update max number of vCPUs supported for x2AVIC mode > KVM: SVM: Update avic_kick_target_vcpus to support 32-bit APIC ID > KVM: SVM: Do not support updating APIC ID when in x2APIC mode > KVM: SVM: Adding support for configuring x2APIC MSRs interception > KVM: x86: Deactivate APICv on vCPU with APIC disabled > KVM: SVM: Refresh AVIC configuration when changing APIC mode > KVM: SVM: Introduce logic to (de)activate x2AVIC mode > KVM: SVM: Do not throw warning when calling avic_vcpu_load on a > running vcpu > KVM: SVM: Introduce hybrid-AVIC mode > KVM: x86: Warning APICv inconsistency only when vcpu APIC mode is > valid > KVM: SVM: Use target APIC ID to complete x2AVIC IRQs when possible > KVM: SVM: Add AVIC doorbell tracepoint > > arch/x86/hyperv/hv_apic.c | 2 +- > arch/x86/include/asm/apicdef.h | 4 +- > arch/x86/include/asm/cpufeatures.h | 1 + > arch/x86/include/asm/kvm_host.h | 1 - > arch/x86/include/asm/svm.h | 16 ++- > arch/x86/kernel/apic/apic.c | 2 +- > arch/x86/kernel/apic/ipi.c | 2 +- > arch/x86/kvm/lapic.c | 6 +- > arch/x86/kvm/svm/avic.c | 178 ++++++++++++++++++++++++++--- > arch/x86/kvm/svm/nested.c | 5 + > arch/x86/kvm/svm/svm.c | 75 ++++++++---- > arch/x86/kvm/svm/svm.h | 25 +++- > arch/x86/kvm/trace.h | 18 +++ > arch/x86/kvm/x86.c | 8 +- > 14 files changed, 291 insertions(+), 52 deletions(-) > > -- > 2.25.1 When will we see this feature in silicon? Where is the official documentation?