From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB9B3FA3728 for ; Thu, 17 Oct 2019 02:12:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B20EA21928 for ; Thu, 17 Oct 2019 02:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390098AbfJQCMc convert rfc822-to-8bit (ORCPT ); Wed, 16 Oct 2019 22:12:32 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:35772 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729268AbfJQCMc (ORCPT ); Wed, 16 Oct 2019 22:12:32 -0400 Received: from DGGEMM406-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id 55D68A55E48D057E22C8; Thu, 17 Oct 2019 10:12:30 +0800 (CST) Received: from dggeme713-chm.china.huawei.com (10.1.199.109) by DGGEMM406-HUB.china.huawei.com (10.3.20.214) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 17 Oct 2019 10:12:29 +0800 Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by dggeme713-chm.china.huawei.com (10.1.199.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 17 Oct 2019 10:12:29 +0800 Received: from dggeme763-chm.china.huawei.com ([10.6.66.36]) by dggeme763-chm.china.huawei.com ([10.6.66.36]) with mapi id 15.01.1713.004; Thu, 17 Oct 2019 10:12:29 +0800 From: linmiaohe To: Vitaly Kuznetsov CC: "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Mingfangsen , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "sean.j.christopherson@intel.com" , "wanpengli@tencent.com" , "jmattson@google.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" Subject: Re: [PATCH] KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update Thread-Topic: [PATCH] KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update Thread-Index: AdWEjr+4z8yau3AyRuWN8bh3iu3VDg== Date: Thu, 17 Oct 2019 02:12:29 +0000 Message-ID: <7db9f15500ab486b897bf1a7fa7e7161@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.184.189.20] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Vitaly Kuznetsov writes: >> Guest physical APIC ID may not equal to vcpu->vcpu_id in some case. >> We may set the wrong physical id in avic_handle_ldr_update as we >> always use vcpu->vcpu_id. Hi, Vitaly, thanks for your reply. Do you think there may be a wrong physical id in avic_handle_ldr_update too ? >> >> @@ -4591,6 +4591,8 @@ static int avic_handle_ldr_update(struct kvm_vcpu *vcpu) >> int ret = 0; >> struct vcpu_svm *svm = to_svm(vcpu); >> u32 ldr = kvm_lapic_get_reg(vcpu->arch.apic, APIC_LDR); >> + u32 apic_id_reg = kvm_lapic_get_reg(vcpu->arch.apic, APIC_ID); >> + u32 id = (apic_id_reg >> 24) & 0xff; > >If we reach here than we're guaranteed to be in xAPIC mode, right? Could you maybe export and use kvm_xapic_id() here then (and in >avic_handle_apic_id_update() too)? > I think we're guaranteed to be in xAPIC mode when we reach here. I would have a try to export and use use kvm_xapic_id here and in avic_handle_apic_id_update too. Thanks for your suggestion. Have a nice day. Best wishes.