From patchwork Wed Dec 4 19:07:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02D076C1 for ; Wed, 4 Dec 2019 19:07:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D422620803 for ; Wed, 4 Dec 2019 19:07:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Xa4l98rX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728845AbfLDTHz (ORCPT ); Wed, 4 Dec 2019 14:07:55 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22921 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728465AbfLDTHb (ORCPT ); Wed, 4 Dec 2019 14:07:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486450; 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=kn/llSEPws9Kaihse6HkAcboPO6kvjhOBVqBu50kJWM=; b=Xa4l98rXBnGh+ETCe0JsN0hNfWFnevNFNopEHcMO5FXqk7R63sKowkrOsuC8BBkEKGbRFz sLk/y4Pc0NnvIGLhvVV0tNG0MoNm5xUwbdxCgyKqc+myTYujLjwP/yQlRvZy/S6sTP5Gr2 oqJ9wh5O1E068gIUf+sHP/pxh+Rr3F8= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-GoAYR2thN3OqKKq4YoRjjQ-1; Wed, 04 Dec 2019 14:07:25 -0500 Received: by mail-qv1-f71.google.com with SMTP id m43so456585qvc.17 for ; Wed, 04 Dec 2019 11:07:25 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qDMFszQpTCz8aKUy2p2BRtrOo8b1SfrY7qPPp6I+jnk=; b=qkCqBXhWxRg4ZYk+lHtKleZ3fAY86tuHPIQ7imzKXYDM8I9TvuQzpi4XMUcJGjd14m 7uQ71HNXtaKbgdH2KMLNJkug4VO+zWVY9xpNuVJNoiPr/EUWKMmS7vQtYJ3NSFfes1Xe +yFDxczvfPt8B4hDNa91u/lKAF9FQ5vmi2mgSeXWauDP49QvHfIUxpGdqeiQbQnW56C8 5iXWlph8O3Q/xxNB7TAvYlIDOs2KBZiTsGEOxFxSWT1Jhrfd/mqfdFrZ6sSS0uYVSq5c 0ejrwpZ6Jahwo5ien0gK3JN4M1QhY9ZFrCbbSTzuIZp2tutYGsBIpva8uytISVH7GlkL 03Tw== X-Gm-Message-State: APjAAAWUzQpJ3fIYcqJ4JXE0t6SKVCaDB8dh8dG0QHCRyU+Gk5yK9nmX GRXcwuz617FOdiPnzJ6HEmrIvV2KlduKY/fcU3Flakx+ZcIo9aZi8Xk3olFYbCukZ6GIUKmvUa9 pWFMTdS1rQCep X-Received: by 2002:a37:f605:: with SMTP id y5mr4645601qkj.59.1575486444772; Wed, 04 Dec 2019 11:07:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwXcJerAYwuG8Nz4ZOyamZB1Cf11CnFdKyqm2/DvrswGbmWblNXhZd72Q8pcAs4X10qlKVa5A== X-Received: by 2002:a37:f605:: with SMTP id y5mr4645584qkj.59.1575486444531; Wed, 04 Dec 2019 11:07:24 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:23 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 1/6] KVM: X86: Fix kvm_bitmap_or_dest_vcpus() to use irq shorthand Date: Wed, 4 Dec 2019 14:07:16 -0500 Message-Id: <20191204190721.29480-2-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: GoAYR2thN3OqKKq4YoRjjQ-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The 3rd parameter of kvm_apic_match_dest() is the irq shorthand, rather than the irq delivery mode. Fixes: 7ee30bc132c6 ("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs") Reviewed-by: Vitaly Kuznetsov Signed-off-by: Peter Xu --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index cf9177b4a07f..1eabe58bb6d5 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1151,7 +1151,7 @@ void kvm_bitmap_or_dest_vcpus(struct kvm *kvm, struct kvm_lapic_irq *irq, if (!kvm_apic_present(vcpu)) continue; if (!kvm_apic_match_dest(vcpu, NULL, - irq->delivery_mode, + irq->shorthand, irq->dest_id, irq->dest_mode)) continue; From patchwork Wed Dec 4 19:07:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 801F86C1 for ; Wed, 4 Dec 2019 19:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51F0820656 for ; Wed, 4 Dec 2019 19:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dW1/Yr9A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728850AbfLDTHa (ORCPT ); Wed, 4 Dec 2019 14:07:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56662 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728465AbfLDTH3 (ORCPT ); Wed, 4 Dec 2019 14:07:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486448; 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=5z9DSSJjWBkwMoPX0AiQMG2lTnPniK2p7yuPt+JjwOw=; b=dW1/Yr9AjXRBv++0H2kZH7LV0QHuZyc3aw1cBRWAasn6dHNcbYw+pbLH7LXrSJubNWp54+ MQjCU3eMGDhG6B8tgoPQR66czZS4hIPnEJKq6LQZUyNlHt+TNOpb/4pF0IzZ1WkAg/wnvP 2VHSnqlS3kdIIULesHWj0x/xl4bj704= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-jBaVcA1BMuuhqDAbqYFOnQ-1; Wed, 04 Dec 2019 14:07:26 -0500 Received: by mail-qk1-f198.google.com with SMTP id q125so451018qka.1 for ; Wed, 04 Dec 2019 11:07:26 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v2wRBhbJMNEdghlygF10/9hA60Iod/Z62OhKSAkteiI=; b=Axl2nvhV37wmGukV+VNB6PV9pKriuaQoI62DoFj3waWssp6tfK+PSRX3URwt3r8Ap5 DAnJnHKwya8ZCUgRQuAvvDP7N/wLJYCj2YUpqVm5kX0O53V+q8Fade1PvgoynG4iepaA l17vL/I7XQbmZGwmQFMZhT/Aw16SXGApMV6og8LfWthXykFI0RrQU/UC6yySqTWyNcDG FVRIiLs2gC7rIDJvb2WhYNHgwwmHD1dB8BzANPNldmBvfcbJ7aAjmZjr6UOTTLGQNzV8 sIPLOyD/3ZH2/dtv9MDfuNd9H2Hf63q2FAmcnHRr3vHsmNdKIr8OEzsQeR4jMXkytsUb 0aYg== X-Gm-Message-State: APjAAAW5RcD/sLkZDEIUpaz85E8nDfPr3EP0x/q1k/O1RCYAV/uZTFXE DWaQ3cxTA74z/DSgY/xJxq88ckVXXfwJWnKM+zfIdg/Dk8R02fTDABzhHwWHHudCG1zlxEWDRqS IZD73KAfI3blJ X-Received: by 2002:a37:b283:: with SMTP id b125mr4764052qkf.352.1575486446404; Wed, 04 Dec 2019 11:07:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzRevtH1T5mqVjOK0YkaXbvotY+Dzc53TaR3BgA35JFGZAZOoqoBMsySDC6Tdp4+EoNNPc1dA== X-Received: by 2002:a37:b283:: with SMTP id b125mr4764022qkf.352.1575486446139; Wed, 04 Dec 2019 11:07:26 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:25 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 2/6] KVM: X86: Move irrelevant declarations out of ioapic.h Date: Wed, 4 Dec 2019 14:07:17 -0500 Message-Id: <20191204190721.29480-3-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: jBaVcA1BMuuhqDAbqYFOnQ-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org kvm_apic_match_dest() is declared in both ioapic.h and lapic.h. Remove the declaration in ioapic.h. kvm_apic_compare_prio() is declared in ioapic.h but defined in lapic.c. Move the declaration to lapic.h. kvm_irq_delivery_to_apic() is declared in ioapic.h but defined in irq_comm.c. Move the declaration to irq.h. hyperv.c needs to use kvm_irq_delivery_to_apic(). Include irq.h in hyperv.c. Reviewed-by: Vitaly Kuznetsov Signed-off-by: Peter Xu --- arch/x86/kvm/hyperv.c | 1 + arch/x86/kvm/ioapic.h | 6 ------ arch/x86/kvm/irq.h | 3 +++ arch/x86/kvm/lapic.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 23ff65504d7e..c7d4640b7b1c 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -33,6 +33,7 @@ #include #include "trace.h" +#include "irq.h" #define KVM_HV_MAX_SPARSE_VCPU_SET_BITS DIV_ROUND_UP(KVM_MAX_VCPUS, 64) diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index ea1a4e0297da..2fb2e3c80724 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -116,9 +116,6 @@ static inline int ioapic_in_kernel(struct kvm *kvm) } void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu); -bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, - int short_hand, unsigned int dest, int dest_mode); -int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); void kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, int vector, int trigger_mode); int kvm_ioapic_init(struct kvm *kvm); @@ -126,9 +123,6 @@ void kvm_ioapic_destroy(struct kvm *kvm); int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id, int level, bool line_status); void kvm_ioapic_clear_all(struct kvm_ioapic *ioapic, int irq_source_id); -int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, - struct dest_map *dest_map); void kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); void kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index 7c6233d37c64..f173ab6b407e 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h @@ -113,5 +113,8 @@ int apic_has_pending_timer(struct kvm_vcpu *vcpu); int kvm_setup_default_irq_routing(struct kvm *kvm); int kvm_setup_empty_irq_routing(struct kvm *kvm); +int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, + struct kvm_lapic_irq *irq, + struct dest_map *dest_map); #endif diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 39925afdfcdc..0b9bbadd1f3c 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -83,7 +83,7 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, void *data); bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, int short_hand, unsigned int dest, int dest_mode); - +int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); bool __kvm_apic_update_irr(u32 *pir, void *regs, int *max_irr); bool kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir, int *max_irr); void kvm_apic_update_ppr(struct kvm_vcpu *vcpu); From patchwork Wed Dec 4 19:07:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59AA26C1 for ; Wed, 4 Dec 2019 19:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BD2A20803 for ; Wed, 4 Dec 2019 19:07:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gs1qW1TU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729049AbfLDTHs (ORCPT ); Wed, 4 Dec 2019 14:07:48 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50538 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728900AbfLDTHd (ORCPT ); Wed, 4 Dec 2019 14:07:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486452; 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=gWYRCGS0//yIHflQIbqt67u02lc6zBx08hdFYmA1GAk=; b=gs1qW1TUrfh8C/THwY2fSNXCLbGG6oKsjq6PhhCcqbLBvhMAEjtIC3NQe3yAfE7s5Gij8m mt8BmfP8jfa7RKtRfJOx3EXbEujPoZpjshzexmyYV5B1botpknKmVjkAb7XKUYaxm8JtdX qBcQThYTCmmzNGT39bAobpLKiyaBbDY= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-c2Jn-AeAOkyYeto2xKgpCA-1; Wed, 04 Dec 2019 14:07:28 -0500 Received: by mail-qv1-f69.google.com with SMTP id p9so444727qvq.22 for ; Wed, 04 Dec 2019 11:07:28 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eAtukvvxHZFb5VfwsHBqC9apLrG0d1NIt4uAdArUNm4=; b=bSTG1j1QrqBuAcMEeTarJm9PReXeWLA5CmStDTIb24Vto+p524Ad3y9JqrsyWpMoN+ OpeWbj89JfCzOVL+Th0AsGSKhIhH74esgJP2aSoWCGpJCTkdqKXghXZcXuK/SdVmpm5j AOMFXmg6TiG4FeO00QNltXYCDXR/xRQmpJ/JTbhBR2brDrC0IdOhUf3462PpksLCgflo EVnVCKCLEhtnWXGGBekYEa+ArZVhgbWHC6EGFviW8aRIHdqbg2G/ERQGfRIW1Dbuipzi NrlotD1LwNK8plY3zvZpqkLOHLUeKtAr0R1K1ChUYYkAySIF8b50BJz3oTbjPeZH8YM3 AQsw== X-Gm-Message-State: APjAAAXIaCkAjKuyxnNrumprhsVl+DvJASiz7XjohVZn/2DgrtGNpvSK KiYCKkzEMe37cpFBAG3jOPqUgcvpjkFGIFtXznVu8p+9CcHZ25Cm3+qhnU1ZjeWXzPKuY213nFx wO8uPDI3Sx3nA X-Received: by 2002:a05:620a:14bc:: with SMTP id x28mr4687583qkj.494.1575486447918; Wed, 04 Dec 2019 11:07:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxW8R5iCT8mNJ0NFxLhS+5m2yw8n1xSpxtGhj4i8JeVRP3YpcplU7Q1uOA3EQltVVXpat/Y6Q== X-Received: by 2002:a05:620a:14bc:: with SMTP id x28mr4687547qkj.494.1575486447611; Wed, 04 Dec 2019 11:07:27 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:26 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 3/6] KVM: X86: Use APIC_DEST_* macros properly in kvm_lapic_irq.dest_mode Date: Wed, 4 Dec 2019 14:07:18 -0500 Message-Id: <20191204190721.29480-4-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: c2Jn-AeAOkyYeto2xKgpCA-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We were using either APIC_DEST_PHYSICAL|APIC_DEST_LOGICAL or 0|1 to fill in kvm_lapic_irq.dest_mode. It's fine only because in most cases when we check against dest_mode it's against APIC_DEST_PHYSICAL (which equals to 0). However, that's not consistent. We'll have problem when we want to start checking against APIC_DEST_LOGICAL, which does not equals to 1. This patch firstly introduces kvm_lapic_irq_dest_mode() helper to take any boolean of destination mode and return the APIC_DEST_* macro. Then, it replaces the 0|1 settings of irq.dest_mode with the helper. Signed-off-by: Peter Xu --- arch/x86/include/asm/kvm_host.h | 5 +++++ arch/x86/kvm/ioapic.c | 9 ++++++--- arch/x86/kvm/irq_comm.c | 7 ++++--- arch/x86/kvm/x86.c | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index b79cd6aa4075..2893eae5df9f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1022,6 +1022,11 @@ struct kvm_lapic_irq { bool msi_redir_hint; }; +static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical) +{ + return dest_mode_logical ? APIC_DEST_LOGICAL : APIC_DEST_PHYSICAL; +} + struct kvm_x86_ops { int (*cpu_has_kvm_support)(void); /* __init */ int (*disabled_by_bios)(void); /* __init */ diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 9fd2dd89a1c5..e623a4f8d27e 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -331,7 +331,8 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode << 8; irq.dest_id = e->fields.dest_id; - irq.dest_mode = e->fields.dest_mode; + irq.dest_mode = + kvm_lapic_irq_dest_mode(!!e->fields.dest_mode); bitmap_zero(&vcpu_bitmap, 16); kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq, &vcpu_bitmap); @@ -343,7 +344,9 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) * keep ioapic_handled_vectors synchronized. */ irq.dest_id = old_dest_id; - irq.dest_mode = old_dest_mode; + irq.dest_mode = + kvm_lapic_irq_dest_mode( + !!e->fields.dest_mode); kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq, &vcpu_bitmap); } @@ -369,7 +372,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) irqe.dest_id = entry->fields.dest_id; irqe.vector = entry->fields.vector; - irqe.dest_mode = entry->fields.dest_mode; + irqe.dest_mode = kvm_lapic_irq_dest_mode(!!entry->fields.dest_mode); irqe.trig_mode = entry->fields.trig_mode; irqe.delivery_mode = entry->fields.delivery_mode << 8; irqe.level = 1; diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index 8ecd48d31800..22108ed66a76 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -52,8 +52,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, unsigned long dest_vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)]; unsigned int dest_vcpus = 0; - if (irq->dest_mode == 0 && irq->dest_id == 0xff && - kvm_lowest_prio_delivery(irq)) { + if (irq->dest_mode == APIC_DEST_PHYSICAL && + irq->dest_id == 0xff && kvm_lowest_prio_delivery(irq)) { printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n"); irq->delivery_mode = APIC_DM_FIXED; } @@ -114,7 +114,8 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, irq->dest_id |= MSI_ADDR_EXT_DEST_ID(e->msi.address_hi); irq->vector = (e->msi.data & MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT; - irq->dest_mode = (1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo; + irq->dest_mode = kvm_lapic_irq_dest_mode( + !!((1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo)); irq->trig_mode = (1 << MSI_DATA_TRIGGER_SHIFT) & e->msi.data; irq->delivery_mode = e->msi.data & 0x700; irq->msi_redir_hint = ((e->msi.address_lo diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3ed167e039e5..3b00d662dc14 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7356,7 +7356,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) struct kvm_lapic_irq lapic_irq; lapic_irq.shorthand = 0; - lapic_irq.dest_mode = 0; + lapic_irq.dest_mode = APIC_DEST_PHYSICAL; lapic_irq.level = 0; lapic_irq.dest_id = apicid; lapic_irq.msi_redir_hint = false; From patchwork Wed Dec 4 19:07:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39C5A6C1 for ; Wed, 4 Dec 2019 19:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16F7320803 for ; Wed, 4 Dec 2019 19:07:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Drq/KvQj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbfLDTHs (ORCPT ); Wed, 4 Dec 2019 14:07:48 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26415 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728883AbfLDTHd (ORCPT ); Wed, 4 Dec 2019 14:07:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486452; 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=14g8RaA5piWvH+2ustd/wNI5q+TQc8KxgzZhf+/2kiM=; b=Drq/KvQjAtk1pnoHS+iAq/3ejzViWgOUFx3BUGf0nepk5U7Zyx/TxJeTyKasdlr+OMl/SV EYy5ScqWWULOM94Rw2UGMmb8URPnHGttqtnrCyWXvLcSKqIMKp4PBk0/l22nMyoDtIiZjt QVGAVI6SsrKt9pr2INgk1YStm9XR0Bc= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-45E4NY4nPH-NSSanuVtM-w-1; Wed, 04 Dec 2019 14:07:30 -0500 Received: by mail-qt1-f200.google.com with SMTP id t20so641098qtr.3 for ; Wed, 04 Dec 2019 11:07:30 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dMSAhkBc+XDUp7X0JKW/OfiFquvplAZgCqXULfdRF2I=; b=oX1IB/mnlR0C9mOeFhRAP9L6zIRWDeqNO2L2pmAuqYnwev87agkhZHjrW+ppob+vGP AkgGvlC++kfin1lB7SPFV9iqv6EJIuePs7MzaI7JXLBvpXOSTOW752/JYaOecpmpae6x t7iWd+8k5e5EiJfUKtmyRgbacS4UPryFjUBZSYlJplyuhDBnNywpt7x6pSog68n5C7WP vvSB5A4uklArGWe5RhaZfu0rVQHynO2My0Fj8+ew9UBtrrwfiFSOd8oFiNUmk3SVze4Y e4UCVsCGOT0nJb2E+3bd7o3r5XCQxP/hANIz7JfsOQNGvDs0GlliPWfROp0w/e2N1jF/ crHA== X-Gm-Message-State: APjAAAXpRugS0q6UjYIO7UjuQH0WNwm7hQ7wrA9rgp+u8X+Z6i3Ln6bD cCh8xpKGWLTgs2jnXB1X2+TOYtm9k1k7haqlhA0Ge8YRVKMCbg4w4j+Ne1mU4hBoOJdodtrt17n VU2G07n3OQ6/O X-Received: by 2002:a37:62c4:: with SMTP id w187mr4623785qkb.121.1575486449611; Wed, 04 Dec 2019 11:07:29 -0800 (PST) X-Google-Smtp-Source: APXvYqx342LHgJ8Z4Al1qN577PBjCuf9DkQOJEwuuV8mZT8Sv3S0edfBKQdU7LsMR1sARS/2KXJbvQ== X-Received: by 2002:a37:62c4:: with SMTP id w187mr4623754qkb.121.1575486449366; Wed, 04 Dec 2019 11:07:29 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:28 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 4/6] KVM: X86: Drop KVM_APIC_SHORT_MASK and KVM_APIC_DEST_MASK Date: Wed, 4 Dec 2019 14:07:19 -0500 Message-Id: <20191204190721.29480-5-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: 45E4NY4nPH-NSSanuVtM-w-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We have both APIC_SHORT_MASK and KVM_APIC_SHORT_MASK defined for the shorthand mask. Similarly, we have both APIC_DEST_MASK and KVM_APIC_DEST_MASK defined for the destination mode mask. Drop the KVM_APIC_* macros and replace the only user of them to use the APIC_DEST_* macros instead. At the meantime, move APIC_SHORT_MASK and APIC_DEST_MASK from lapic.c to lapic.h. Reviewed-by: Vitaly Kuznetsov Signed-off-by: Peter Xu --- arch/x86/kvm/lapic.c | 3 --- arch/x86/kvm/lapic.h | 5 +++-- arch/x86/kvm/svm.c | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 1eabe58bb6d5..805c18178bbf 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -56,9 +56,6 @@ #define APIC_VERSION (0x14UL | ((KVM_APIC_LVT_NUM - 1) << 16)) #define LAPIC_MMIO_LENGTH (1 << 12) /* followed define is not in apicdef.h */ -#define APIC_SHORT_MASK 0xc0000 -#define APIC_DEST_NOSHORT 0x0 -#define APIC_DEST_MASK 0x800 #define MAX_APIC_VECTOR 256 #define APIC_VECTORS_PER_REG 32 diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 0b9bbadd1f3c..5a9f29ed9a4b 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -10,8 +10,9 @@ #define KVM_APIC_SIPI 1 #define KVM_APIC_LVT_NUM 6 -#define KVM_APIC_SHORT_MASK 0xc0000 -#define KVM_APIC_DEST_MASK 0x800 +#define APIC_SHORT_MASK 0xc0000 +#define APIC_DEST_NOSHORT 0x0 +#define APIC_DEST_MASK 0x800 #define APIC_BUS_CYCLE_NS 1 #define APIC_BUS_FREQUENCY (1000000000ULL / APIC_BUS_CYCLE_NS) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 362e874297e4..65a27a7e9cb1 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4519,9 +4519,9 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm) */ kvm_for_each_vcpu(i, vcpu, kvm) { bool m = kvm_apic_match_dest(vcpu, apic, - icrl & KVM_APIC_SHORT_MASK, + icrl & APIC_SHORT_MASK, GET_APIC_DEST_FIELD(icrh), - icrl & KVM_APIC_DEST_MASK); + icrl & APIC_DEST_MASK); if (m && !avic_vcpu_is_running(vcpu)) kvm_vcpu_wake_up(vcpu); From patchwork Wed Dec 4 19:07:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3C8D6C1 for ; Wed, 4 Dec 2019 19:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7EEC2073B for ; Wed, 4 Dec 2019 19:07:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IYiQTObg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728858AbfLDTHg (ORCPT ); Wed, 4 Dec 2019 14:07:36 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:28474 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728941AbfLDTHg (ORCPT ); Wed, 4 Dec 2019 14:07:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486454; 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=5Lq/P7d+cEs1tdKkoIRD5hhXJQvr8MIiHNwX65PAnnk=; b=IYiQTObgrdhe5Wd6ZbDg6x7fYnd1jX2lgf2/cAajdyugP6GJSxhOOO64LfkSfX/4DgZL4C myIwSOJJbEVSNAMvmer0dPuAulyHOrmyWRqwvckXhX+vvGIejW6WkmckcAjsM3Bt38eSI2 XJLsyW58xv0duxSG5O2TZ6gSHxOSaSI= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-mscxAyZSOGmfS-G8jRUgVA-1; Wed, 04 Dec 2019 14:07:32 -0500 Received: by mail-qt1-f200.google.com with SMTP id u9so637087qte.5 for ; Wed, 04 Dec 2019 11:07:31 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/aw+fRGlH+N9W78xqsOuN+obHGUmDvFS1ddeXRADj4A=; b=LcuN4aC3Kxs+U+itMtQYfhN5oP6slrz2s5Pnu5q9EL+4gw1JkvaTlhaR05PPSdEvWr x5OaOp7W3b/oqPaPDkPcsdYaBB9+sJAGK3azweAyXoDzKyfc5O0hLMec51416jCiepJP AxyouClTiKn3jFqpaiWtCkSKBEeolpu2rvODDcRlCj6Qg0rP5aHKl2XtQp6MQwjEhTax WkDg87aa2el2ySp0OjODxPIeNaajM/Uab3MOr0ygUJEJVyL8PbDvXa+l7C8Ecevw13k4 p9XLPhWXmQOe/2e6ll12bdGnHEVfLUPA18TLaKAKffjOvEhJV49+khObDoVm3ojLiSCC TfuQ== X-Gm-Message-State: APjAAAX8u9mg79sjBDpPG/PXyo0iy10j45cmGKUFrCd9Ny8Cu4JoGqxE LWz6IIdU9+OooSyCXLaVnMjDqxJ2rpxqtl7IaYN8u3qifWEvHeWyofsd1m8BcNxDPUWGVSOi6+/ FotcoDraziIik X-Received: by 2002:ae9:ec0b:: with SMTP id h11mr4451245qkg.97.1575486451264; Wed, 04 Dec 2019 11:07:31 -0800 (PST) X-Google-Smtp-Source: APXvYqx8nwioxQxIuSeML+K5PHXcsUaOyJVc9LBRDJnxWxf/xvFanlwMCKzVQ3o07cRLheRCNQXaJg== X-Received: by 2002:ae9:ec0b:: with SMTP id h11mr4451216qkg.97.1575486450983; Wed, 04 Dec 2019 11:07:30 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:29 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 5/6] KVM: X86: Fix callers of kvm_apic_match_dest() to use correct macros Date: Wed, 4 Dec 2019 14:07:20 -0500 Message-Id: <20191204190721.29480-6-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: mscxAyZSOGmfS-G8jRUgVA-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Callers of kvm_apic_match_dest() should always pass in APIC_DEST_* macros for either dest_mode and short_hand parameters. Fix up all the callers of kvm_apic_match_dest() that are not following the rule. Since at it, rename the parameter from short_hand to shorthand in kvm_apic_match_dest(), as suggested by Vitaly. Reported-by: Sean Christopherson Reported-by: Vitaly Kuznetsov Reviewed-by: Vitaly Kuznetsov Signed-off-by: Peter Xu --- arch/x86/kvm/ioapic.c | 11 +++++++---- arch/x86/kvm/irq_comm.c | 3 ++- arch/x86/kvm/lapic.c | 4 ++-- arch/x86/kvm/lapic.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index e623a4f8d27e..f53daeaaeb37 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -108,8 +108,9 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) union kvm_ioapic_redirect_entry *e; e = &ioapic->redirtbl[RTC_GSI]; - if (!kvm_apic_match_dest(vcpu, NULL, 0, e->fields.dest_id, - e->fields.dest_mode)) + if (!kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT, + e->fields.dest_id, + kvm_lapic_irq_dest_mode(!!e->fields.dest_mode))) return; new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector); @@ -250,8 +251,10 @@ void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, ulong *ioapic_handled_vectors) if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG || kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index) || index == RTC_GSI) { - if (kvm_apic_match_dest(vcpu, NULL, 0, - e->fields.dest_id, e->fields.dest_mode) || + u16 dm = kvm_lapic_irq_dest_mode(!!e->fields.dest_mode); + + if (kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT, + e->fields.dest_id, dm) || kvm_apic_pending_eoi(vcpu, e->fields.vector)) __set_bit(e->fields.vector, ioapic_handled_vectors); diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index 22108ed66a76..7d083f71fc8e 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -417,7 +417,8 @@ void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu, kvm_set_msi_irq(vcpu->kvm, entry, &irq); - if (irq.level && kvm_apic_match_dest(vcpu, NULL, 0, + if (irq.level && + kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT, irq.dest_id, irq.dest_mode)) __set_bit(irq.vector, ioapic_handled_vectors); } diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 805c18178bbf..679692b55f6d 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -789,13 +789,13 @@ static u32 kvm_apic_mda(struct kvm_vcpu *vcpu, unsigned int dest_id, } bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, - int short_hand, unsigned int dest, int dest_mode) + int shorthand, unsigned int dest, int dest_mode) { struct kvm_lapic *target = vcpu->arch.apic; u32 mda = kvm_apic_mda(vcpu, dest, source, target); ASSERT(target); - switch (short_hand) { + switch (shorthand) { case APIC_DEST_NOSHORT: if (dest_mode == APIC_DEST_PHYSICAL) return kvm_apic_match_physical_addr(target, mda); diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 5a9f29ed9a4b..ec730ce7a344 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -83,7 +83,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val); int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, void *data); bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, - int short_hand, unsigned int dest, int dest_mode); + int shorthand, unsigned int dest, int dest_mode); int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); bool __kvm_apic_update_irr(u32 *pir, void *regs, int *max_irr); bool kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir, int *max_irr); From patchwork Wed Dec 4 19:07:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11273467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A1866C1 for ; Wed, 4 Dec 2019 19:07:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBE4720863 for ; Wed, 4 Dec 2019 19:07:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EeRA3D41" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbfLDTHn (ORCPT ); Wed, 4 Dec 2019 14:07:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41112 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728904AbfLDTHf (ORCPT ); Wed, 4 Dec 2019 14:07:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575486455; 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=uQ4VjfIYrglflf3rJiON69ppSn0JgIlW3dfwal7bm4Y=; b=EeRA3D41wXEQiRMiEyMJexXrOYJdn4XqGJeffTMr6CERsxxAlkZpvY2MgqFTtffUu8WgbW WpBpnON6bTnHErrINyfrtUtw/biqF8g6i5sd9Hxq8rZ4wFKrXEvcCZbU9nEfqzylpTfAla /O08fG3pEHvgmRhF6CXT+2HqBE0anPY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-EbTqCLGlOtWVaW02Hf5MlA-1; Wed, 04 Dec 2019 14:07:33 -0500 Received: by mail-qv1-f72.google.com with SMTP id c22so488321qvc.1 for ; Wed, 04 Dec 2019 11:07:33 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wqX1WpDnk793hPGykZVwJa0dz2ySQCsCHFOl+w7F7+Q=; b=mge7paRSg32UNbXkyvGiyFyViFIddtkxIN1DWbiRjROD/zKUe7BHnbOt/SlbPutxIR pQE8hicvaF+GKtqDB3LYStF5IY3EhmmE9y1SJ5bpJi6GPbOnUpy3B53C5Xm/TG1WHl1E alYwU2XYGp8PuKVdUeh52TnXpaooxaoNFQiw5lsyPZRW8zL/zvb/4sEthqfzKw99IBZv HUyDOOBA1qEd29p87l7BvIbzTTUzbuz/dB97kACl7ngZqLOhllxmyvHjonXAgqycxZZ4 cLPR4O0KsvcTVVfyv6KDPvKHDzxDbVUr5Hzd/g0Iht+cp9hTbEivVKwWiTKv6Vr2pF1S 1ZPg== X-Gm-Message-State: APjAAAWPaE8ODVc4WOBKzOuTZxbEGRvt/MS7CtLx5Sg4Rn85Sqz6qkpl mejV0XaC9qTyvsZ3ep8wV08AhBzw84SVEzmlGRlACqfw2WFcYW0Jr2z2q5HWuLQ09IDFE+Riw/l EF4jnYH55aG/9 X-Received: by 2002:ad4:4908:: with SMTP id bh8mr4161476qvb.251.1575486452789; Wed, 04 Dec 2019 11:07:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwEvT/Ded38f7safdU21KIFiL1aXou5MYGRU1P1kBbugrZwGKwljjsV/vT2lZcdGelzIUricw== X-Received: by 2002:ad4:4908:: with SMTP id bh8mr4161445qvb.251.1575486452527; Wed, 04 Dec 2019 11:07:32 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id y18sm4072126qtn.11.2019.12.04.11.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:07:31 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Nitesh Narayan Lal , Paolo Bonzini , Sean Christopherson , peterx@redhat.com, Vitaly Kuznetsov Subject: [PATCH v5 6/6] KVM: X86: Conert the last users of "shorthand = 0" to use macros Date: Wed, 4 Dec 2019 14:07:21 -0500 Message-Id: <20191204190721.29480-7-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191204190721.29480-1-peterx@redhat.com> References: <20191204190721.29480-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: EbTqCLGlOtWVaW02Hf5MlA-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Change the last users of "shorthand = 0" to use APIC_DEST_NOSHORT. Reviewed-by: Vitaly Kuznetsov Signed-off-by: Peter Xu --- arch/x86/kvm/ioapic.c | 4 ++-- arch/x86/kvm/irq_comm.c | 2 +- arch/x86/kvm/x86.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index f53daeaaeb37..77538fd77dc2 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -330,7 +330,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) if (e->fields.delivery_mode == APIC_DM_FIXED) { struct kvm_lapic_irq irq; - irq.shorthand = 0; + irq.shorthand = APIC_DEST_NOSHORT; irq.vector = e->fields.vector; irq.delivery_mode = e->fields.delivery_mode << 8; irq.dest_id = e->fields.dest_id; @@ -379,7 +379,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) irqe.trig_mode = entry->fields.trig_mode; irqe.delivery_mode = entry->fields.delivery_mode << 8; irqe.level = 1; - irqe.shorthand = 0; + irqe.shorthand = APIC_DEST_NOSHORT; irqe.msi_redir_hint = false; if (irqe.trig_mode == IOAPIC_EDGE_TRIG) diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index 7d083f71fc8e..9d711c2451c7 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -121,7 +121,7 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, irq->msi_redir_hint = ((e->msi.address_lo & MSI_ADDR_REDIRECTION_LOWPRI) > 0); irq->level = 1; - irq->shorthand = 0; + irq->shorthand = APIC_DEST_NOSHORT; } EXPORT_SYMBOL_GPL(kvm_set_msi_irq); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3b00d662dc14..f6d778436e15 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7355,7 +7355,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) { struct kvm_lapic_irq lapic_irq; - lapic_irq.shorthand = 0; + lapic_irq.shorthand = APIC_DEST_NOSHORT; lapic_irq.dest_mode = APIC_DEST_PHYSICAL; lapic_irq.level = 0; lapic_irq.dest_id = apicid;