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=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 4725EC432C0 for ; Fri, 29 Nov 2019 16:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19C942176D for ; Fri, 29 Nov 2019 16:32:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jOc8isZJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727184AbfK2Qcv (ORCPT ); Fri, 29 Nov 2019 11:32:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28548 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727079AbfK2Qcq (ORCPT ); Fri, 29 Nov 2019 11:32:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575045165; 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=YdjqiuhcZ58rcqgBhxb9lvVnvVL8Yk36IVCo28ntw5s=; b=jOc8isZJQtlTkjAgo0VnrohVrs9mwWjowNCOj9dVO1CMdHU4r0o6IWHh+ucU5z51auH+cu 3w5wIf3QyMxXtXq1ZH8QrCc93A+XrYV+thZq+mrYD3U0O6XwEeZ4gAb3uNs4Aj2s8QZWEW Q1infbgLt83eopcDuXv1WJRAL/9y+U0= 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-154-6wxxaA6AOQKSkY0Cszmi1w-1; Fri, 29 Nov 2019 11:32:42 -0500 Received: by mail-qv1-f69.google.com with SMTP id m43so19166284qvc.17 for ; Fri, 29 Nov 2019 08:32:42 -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=pF321W2AO34u1L6FQdPVoWqPwEEaGFwdyk4B7rVy65s=; b=dP+V2PHO07bFe5o2UhhFZtrKp+/cwvsAS5GB5FQqeKFZtX4GpWGg6T0dmjCQxNYCqv 8xnRJ9BTQn8KOkvuEOGDFNkoZx2DRM421lcgwAQiaYd4st9XmD5fLNpuybFYQRQkFJJl N/FpYRh1taa3eNcOA1zrobjQrzPyhUUOY6d41m8mkxIBAJjFd10nT2ht9vWGxh8T7/b2 XFFu7jq5ugynHh7kNeo9vulYyC0ORzlVdwE3k6qrDtxxnD40rMtfs0Ze4oSfMAy74VjR 0Oo+5d0uV3GebhMGbJ4WmFTRjWpaJBzza/NEVRCjrcB48CbtiYIR5bVPxyNP7ue9jNpP OkAg== X-Gm-Message-State: APjAAAWJtpOh8OrVeVodWxRdow7HaxU/1EKeck57DBeOf0YPNTsDl219 wWm3fXa0rxyGq08NmCys9SccLpjEnBL5PO23KsDPHjvRhhdTvWfiD4T6Alav91A2qYiHv3a5vQ8 46KK+4ZbXqLnvefwz8yH6f+be X-Received: by 2002:a37:7dc2:: with SMTP id y185mr16812165qkc.380.1575045161648; Fri, 29 Nov 2019 08:32:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxL2taDIIh634zxS4jLBOiDRC64GcK8w8AVHUAo6D3g58URlp/1EyloE/5HF/qs4zkbAkP1Jw== X-Received: by 2002:a37:7dc2:: with SMTP id y185mr16812137qkc.380.1575045161402; Fri, 29 Nov 2019 08:32:41 -0800 (PST) Received: from xz-x1.yyz.redhat.com ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id d9sm4568329qtj.52.2019.11.29.08.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2019 08:32:39 -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 v2 3/3] KVM: X86: Fixup kvm_apic_match_dest() dest_mode parameter Date: Fri, 29 Nov 2019 11:32:34 -0500 Message-Id: <20191129163234.18902-4-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191129163234.18902-1-peterx@redhat.com> References: <20191129163234.18902-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: 6wxxaA6AOQKSkY0Cszmi1w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The problem is the same as the previous patch on that we've got too many ways to define a dest_mode, but logically we should only pass in APIC_DEST_* macros for this helper. To make it easier, simply define dest_mode of kvm_apic_match_dest() to be a boolean to make it right while we can avoid to touch the callers. Signed-off-by: Peter Xu --- arch/x86/kvm/lapic.c | 5 +++-- arch/x86/kvm/lapic.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index cf9177b4a07f..80732892c709 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -791,8 +791,9 @@ static u32 kvm_apic_mda(struct kvm_vcpu *vcpu, unsigned= int dest_id, =09return dest_id; } =20 +/* Set dest_mode to true for logical mode, false for physical mode */ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, -=09=09=09 int short_hand, unsigned int dest, int dest_mode) +=09=09=09 int short_hand, unsigned int dest, bool dest_mode) { =09struct kvm_lapic *target =3D vcpu->arch.apic; =09u32 mda =3D kvm_apic_mda(vcpu, dest, source, target); @@ -800,7 +801,7 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct = kvm_lapic *source, =09ASSERT(target); =09switch (short_hand) { =09case APIC_DEST_NOSHORT: -=09=09if (dest_mode =3D=3D APIC_DEST_PHYSICAL) +=09=09if (dest_mode =3D=3D false) =09=09=09return kvm_apic_match_physical_addr(target, mda); =09=09else =09=09=09return kvm_apic_match_logical_addr(target, mda); diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 19b36196e2ff..c0b472ed87ad 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -82,7 +82,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, =09=09 void *data); bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, -=09=09=09 int short_hand, unsigned int dest, int dest_mode); +=09=09=09 int short_hand, unsigned int dest, bool dest_mode); int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, =09=09=09 struct kvm_lapic_irq *irq, --=20 2.21.0