Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp350747pxj; Fri, 11 Jun 2021 00:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6J4POINMQYAhwik6FGAwVX/53/QAFfbJD0miHna+TQblV5QAh3lQ/ZRHKDabSzQB3Awx/ X-Received: by 2002:a05:6402:26c2:: with SMTP id x2mr2319925edd.124.1623396095811; Fri, 11 Jun 2021 00:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623396095; cv=none; d=google.com; s=arc-20160816; b=k5Q0lb9WFwIb0AxvEANGupiSKGMgcoLQIXhYbJIsh8LmAoE3dX5KGzHTTObDS9oFnm jPc7Z3OejDqRGP9bturhvs212BY1aotI5AJPqgqae4GG4JkIi8gMNMnVFB3U7SEy6e19 DdWczIPeq2vxBL9MuZ6YsgZubEcUrnp8wHC6FmzIGYRZE4SNm/00G3jM9I8we00aT//m F3gY0bkHmDF7ypC8LdctJV3HytIYJ5MymZX98IWJZ1S+RjDxCoZbuYw9EMcgITV4khX1 1hpZV9ZKBzDOhu4voFG/q4xnYnw4PkoYxKDfu8PPLru7vzkEfZ9yF14GbLnhY1/09CWv gP8g== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=gYjg/yEV7PUq2GYWP2SW746eR9Kq3NCgJS7G1o1Lc6A=; b=Ljjds4CbRvytp5zoSQqy5gWX1KfDuqQCfkgvniRe8enCXOJBhtwCmQgMvIpuCl92Sy Vy06zRPqYgomUmxtb1an1CkH6rt5Aj0+N9dBYa5gjbqjBbr//XT1NWPavxDBcKn3pmmM GD5O6MZLApm1TRr9/0sXetxeQ+iXro3r/SA95ZHZqKgW3Vb54kFhohFtFPbqiHRQgrAd 6V6Ukf8Tj7ZzTJFS0jzyqAGb3YlMYYU2lMK2Fnv0sWccbKqKDXwaUtnwUQjKScjEG2FC IMS0aEDo+OQZ7vifa/MnXVbcLkmS5cuvvcxy1yfexmGLoWSSNhnquq8Ly3NfjyGajvn1 nB+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ev14qAtn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si5222117ejb.722.2021.06.11.00.21.13; Fri, 11 Jun 2021 00:21:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ev14qAtn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbhFKHWQ (ORCPT + 99 others); Fri, 11 Jun 2021 03:22:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42636 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbhFKHWP (ORCPT ); Fri, 11 Jun 2021 03:22:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623396017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gYjg/yEV7PUq2GYWP2SW746eR9Kq3NCgJS7G1o1Lc6A=; b=ev14qAtnULFtl91jy8TroTNm+kgS3wZjhQZhxo1Xs/UgfluVSDzW7C6NWXKO24Gcqa7PLL C3Y35EnBGD1EEhDF4cmN4JnVM0Obc/OD42RtKZcfUnDCLIcasJHY53uKYVX9VTFCi/0nco 2GeG28VNXUW7rGvLY5k36DUkHOOb+AY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198-Bkg0O-XKOui90ltMAJwgVA-1; Fri, 11 Jun 2021 03:20:15 -0400 X-MC-Unique: Bkg0O-XKOui90ltMAJwgVA-1 Received: by mail-wr1-f70.google.com with SMTP id z3-20020adfdf830000b02901198337bc39so2210010wrl.0 for ; Fri, 11 Jun 2021 00:20:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=gYjg/yEV7PUq2GYWP2SW746eR9Kq3NCgJS7G1o1Lc6A=; b=b3EkoHVQjJK4fVlEDlFIBDcKzTNJoU0HEXO0Q7nipu8m1wdRv4bl+Kd15IVOuxM5H+ khJwq55uYy3wrsm8C2qp7qVFkRUQMAg81wcDrBZxIMEgdA5hb43R3PwSAU8//Bm/MRup U/blXH3APQDRv1F30ZREkYbjG6zAu248m+VNHE7sqMoGVqGWTBFbkDFttdJ6vyPIDwB0 FhBALW8k/UYF8hemYrDZlP81VgLNAmb3tb6zxpR6HnFUrf1pEg8XG+M+ipRkxgLiLvDf m7ChJEGSIOoGt0ErYTO+VAtFgV8DpQQmilWcVjPOMD6MGE+Zhj5K/l1eOqpKW8XligtQ UWUA== X-Gm-Message-State: AOAM530XUmic37hEHB2rogh/CSrt6cHH9c6XYvqoEH+7bpCihCeg4fue 8m/64kZ9JMyXM7VYxIM8RLUjMg8zBG22fybRxIZ1VMMPPpZjuZ82EalC6n4FiD9erc68uF+r2sL bymfmgD+oKVCYrOMo/T69AFsl X-Received: by 2002:a05:600c:1d1b:: with SMTP id l27mr2490760wms.62.1623396014347; Fri, 11 Jun 2021 00:20:14 -0700 (PDT) X-Received: by 2002:a05:600c:1d1b:: with SMTP id l27mr2490733wms.62.1623396014106; Fri, 11 Jun 2021 00:20:14 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id m7sm6299020wrv.35.2021.06.11.00.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 00:20:13 -0700 (PDT) From: Vitaly Kuznetsov To: Paolo Bonzini , Vineeth Pillai Cc: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "K. Y. Srinivasan" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, Lan Tianyu , Michael Kelley , Sean Christopherson , Tom Lendacky , Wanpeng Li , Jim Mattson , Joerg Roedel , Wei Liu , Stephen Hemminger , Haiyang Zhang Subject: Re: [PATCH v5 3/7] KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx In-Reply-To: <3b74b538-0b28-7a00-0b26-0f926cd8f37e@redhat.com> References: <4f4e4ca19778437dae502f44363a38e99e3ef5d1.1622730232.git.viremana@linux.microsoft.com> <87y2bix8y1.fsf@vitty.brq.redhat.com> <3b74b538-0b28-7a00-0b26-0f926cd8f37e@redhat.com> Date: Fri, 11 Jun 2021 09:20:12 +0200 Message-ID: <87k0n0yij7.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paolo Bonzini writes: > On 10/06/21 13:20, Vitaly Kuznetsov wrote: > >>> +static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root= _tdp) >>> +{ >>> + struct kvm_arch *kvm_arch =3D &vcpu->kvm->arch; >>> + >>> + if (kvm_x86_ops.tlb_remote_flush =3D=3D hv_remote_flush_tlb) { >>> + spin_lock(&kvm_arch->hv_root_tdp_lock); >>> + vcpu->arch.hv_root_tdp =3D root_tdp; >>> + if (root_tdp !=3D kvm_arch->hv_root_tdp) >>> + kvm_arch->hv_root_tdp =3D INVALID_PAGE; >>> + spin_unlock(&kvm_arch->hv_root_tdp_lock); >>> + } >>> +} >>> +#else >>> +static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root= _tdp) >>> +{ >>> +} >>> +#endif >>> +#endif >>=20 >> Super-nitpick: I'd suggest adding /* __ARCH_X86_KVM_KVM_ONHYPERV_H__ */ >> to the second '#endif' and /* IS_ENABLED(CONFIG_HYPERV) */ to '#else' >> and the first one: files/functions tend to grow and it becomes hard to >> see where the particular '#endif/#else' belongs. > > Done, thanks. I've also changed the #if to just "#ifdef CONFIG_HYPERV",= =20 > since IS_ENABLED is only needed in C statements. kvm/queue fails to compile and I blame this change: In file included from arch/x86/kvm/svm/svm_onhyperv.c:16: arch/x86/kvm/svm/svm_onhyperv.h: In function =E2=80=98svm_hv_hardware_setup= =E2=80=99: arch/x86/kvm/svm/svm_onhyperv.h:56:34: error: =E2=80=98hv_remote_flush_tlb= =E2=80=99 undeclared (first use in this function); did you mean =E2=80=98sv= m_flush_tlb=E2=80=99? 56 | svm_x86_ops.tlb_remote_flush =3D hv_remote_flush_tlb; | ^~~~~~~~~~~~~~~~~~~ | svm_flush_tlb arch/x86/kvm/svm/svm_onhyperv.h:56:34: note: each undeclared identifier is = reported only once for each function it appears in arch/x86/kvm/svm/svm_onhyperv.h:58:5: error: =E2=80=98hv_remote_flush_tlb_w= ith_range=E2=80=99 undeclared (first use in this function) 58 | hv_remote_flush_tlb_with_range; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:272: arch/x86/kvm/svm/svm_onhyperv.o] = Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from arch/x86/kvm/svm/svm.c:47: arch/x86/kvm/svm/svm_onhyperv.h: In function =E2=80=98svm_hv_hardware_setup= =E2=80=99: arch/x86/kvm/svm/svm_onhyperv.h:56:34: error: =E2=80=98hv_remote_flush_tlb= =E2=80=99 undeclared (first use in this function); did you mean =E2=80=98sv= m_flush_tlb=E2=80=99? 56 | svm_x86_ops.tlb_remote_flush =3D hv_remote_flush_tlb; | ^~~~~~~~~~~~~~~~~~~ | svm_flush_tlb arch/x86/kvm/svm/svm_onhyperv.h:56:34: note: each undeclared identifier is = reported only once for each function it appears in arch/x86/kvm/svm/svm_onhyperv.h:58:5: error: =E2=80=98hv_remote_flush_tlb_w= ith_range=E2=80=99 undeclared (first use in this function) 58 | hv_remote_flush_tlb_with_range; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:272: arch/x86/kvm/svm/svm.o] Error 1 arch/x86/kvm/vmx/vmx.c: In function =E2=80=98hardware_setup=E2=80=99: arch/x86/kvm/vmx/vmx.c:7752:34: error: =E2=80=98hv_remote_flush_tlb=E2=80= =99 undeclared (first use in this function) 7752 | vmx_x86_ops.tlb_remote_flush =3D hv_remote_flush_tlb; | ^~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/vmx.c:7752:34: note: each undeclared identifier is reporte= d only once for each function it appears in arch/x86/kvm/vmx/vmx.c:7754:5: error: =E2=80=98hv_remote_flush_tlb_with_ran= ge=E2=80=99 undeclared (first use in this function) 7754 | hv_remote_flush_tlb_with_range; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (Note: CONFIG_HYPERV can be 'm'.) The following: index 96da53edfe83..1c67abf2eba9 100644 --- a/arch/x86/kvm/kvm_onhyperv.h +++ b/arch/x86/kvm/kvm_onhyperv.h @@ -6,7 +6,7 @@ #ifndef __ARCH_X86_KVM_KVM_ONHYPERV_H__ #define __ARCH_X86_KVM_KVM_ONHYPERV_H__ =20 -#ifdef CONFIG_HYPERV +#if IS_ENABLED(CONFIG_HYPERV) int hv_remote_flush_tlb_with_range(struct kvm *kvm, struct kvm_tlb_range *range); int hv_remote_flush_tlb(struct kvm *kvm); saves the day for me. --=20 Vitaly