Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp271167pxb; Mon, 7 Feb 2022 10:55:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwciZRwPGFmSY17sIWGZ34lhgPXO823BwyUiIUsHBGJfnK6JWDi4QqwnrRclMk+tCukIG9r X-Received: by 2002:a17:90a:ea0f:: with SMTP id w15mr314582pjy.181.1644260109117; Mon, 07 Feb 2022 10:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644260109; cv=none; d=google.com; s=arc-20160816; b=KuAiEL6pdeNb4k70rUw80+yMSj79ZbWx9SDzip/VWOjo2hzOAdmJYg58QruBWcGtdp G6CaMPFyHIuQoPVXSQ8YOBeDYb9Iebb5vdXzBMdH0yfP0N+DKOxrOdQig8l54uO9SVO1 iiyMXlH0B45fkE/QM3E8hHtU2ZY3q0JYQ0J995ccN4WzmXTrYIN/xroLn9FC0kSZ51cg 8IVublae4HLTeejqWS1uyGvizeymxeHauQu++OxSglz8KBJszfTXSqsC0otTGuZRKqyq z2KcE0Fop1VtiQia6m6rgaVS+GyyCvqxNTKE1iUHA1ArJj7m0tbbUYCq1qvxE0fG6DD0 ZUXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=KKjH3zCPswTf0hjqacVy5YOkSkhUl6n6cultlDnB9r4=; b=0Iouns1lEtQYFyhK0b95SRCzxeR3S2NGszn/vsqU+KlfpQrb4zfSL+wqmc6T+6QsHH ROz4bpsbqjhW6H+DC3rD4M4DG+/D/hrYmnQ2gq2hgbMVBsiyKFK4GesDgxdby5axoiVa WQgBA+WzSkXEVMuPtp5xn8YE7az39ZGYWr1tNPWGa0hzzZDk6Xwvp59M4Tucit7yNJ8k mxroeJNHl65ksD6wC9IlbRoJvNqJ3qWRO57KJW/aMtQlYQsTWEvzQTaDP9D+TgztN/+F OqftwGDyfEqd+IwiJLqmRABegGmFbMPNDri2cNRHTaJSv4KmYlPXQJhviBrAHy32isQd 3HAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="k/aPC/mM"; 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 y11si11741198plg.343.2022.02.07.10.54.57; Mon, 07 Feb 2022 10:55:09 -0800 (PST) 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="k/aPC/mM"; 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 S244956AbiBDVm3 (ORCPT + 99 others); Fri, 4 Feb 2022 16:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243843AbiBDVmP (ORCPT ); Fri, 4 Feb 2022 16:42:15 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C213CC061714 for ; Fri, 4 Feb 2022 13:42:14 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id m21-20020a17090b069500b001b532620cd9so4288424pjz.1 for ; Fri, 04 Feb 2022 13:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=KKjH3zCPswTf0hjqacVy5YOkSkhUl6n6cultlDnB9r4=; b=k/aPC/mMPGHNoH20HSjvFsILeFwxVaf8/1oUATZ3gMaugfTDdwj3wM6vgZYIU4nQ3n z6bQxP45Mht4VAdettIJ9wpRGDG+RK8Iz2oi2cDaIn1dve93CYueFS85YPJDVlm7axWt S6tW7iL1CnE5gQhMKqG1P2itMRzc1GUcn6ze532LTZLNzyyCbqsnVguGtPc4Bn51JnSJ n4ALN/1fKeUEx0+rL+857zT90+n1A6KUxB7eT/gOidhwqGJMKJ6ERPHmNt+WuXCqVwwe E1J9Tw5Y5jciyjHrZaSljauRntjnYivDlYEAYd/LEYYGf6Kg/du0tG97F/s3umrm4JsG RpDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=KKjH3zCPswTf0hjqacVy5YOkSkhUl6n6cultlDnB9r4=; b=BNo8kqifKfVhlrEdX5hcR33ifFrTb8Ra1sUTk8bLjMwdlpjvVW76Yh4EMbSz3T/x3C 4rZcls4gbGCB2DKWBvUeuMdDxoD3N1ihID+VQ58zgJRGS95tzH8lJwbqqKOJCoBtCaBc Zcr3ztNL3n5SyUKH5giB8pRXO+OUXrGzu4jn/FdGX5FSj1ZVbnYWmhLMouLQCZYNrDis mm2tVEubYwJwzW073ma05VFFfo/mUSOlSIXLggThhsEuf+Il8mfpuQ7supEKdKf/whbn C1yUL/PAcF8ffEjPGfiKxC8ry3rQ1TH+k0HOxewTfNYR3pdX8xrySsCKz0D2gyHoXx6J c3DQ== X-Gm-Message-State: AOAM531zLmKLgZ1AHDxpGoyh0cdBl8ZA+cPYxNX4RGTP+e5g6+V3wjRK WChjhjxIcJkmTBDCb9redRkp9Fx4be8= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:b495:: with SMTP id y21mr5238714plr.82.1644010934301; Fri, 04 Feb 2022 13:42:14 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 4 Feb 2022 21:41:58 +0000 In-Reply-To: <20220204214205.3306634-1-seanjc@google.com> Message-Id: <20220204214205.3306634-5-seanjc@google.com> Mime-Version: 1.0 References: <20220204214205.3306634-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH 04/11] KVM: SVM: Use common kvm_apic_write_nodecode() for AVIC write traps From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zeng Guang , Chao Gao , Maxim Levitsky Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 Use the common kvm_apic_write_nodecode() to handle AVIC/APIC-write traps instead of open coding the same exact code. This will allow making the low level lapic helpers inaccessible outside of lapic.c code. Opportunistically clean up the params to eliminate a bunch of svm=>vcpu reflection. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/avic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index ecc81c48c0ca..462ab073db38 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -476,10 +476,9 @@ static void avic_handle_dfr_update(struct kvm_vcpu *vcpu) svm->dfr_reg = dfr; } -static int avic_unaccel_trap_write(struct vcpu_svm *svm) +static int avic_unaccel_trap_write(struct kvm_vcpu *vcpu) { - struct kvm_lapic *apic = svm->vcpu.arch.apic; - u32 offset = svm->vmcb->control.exit_info_1 & + u32 offset = to_svm(vcpu)->vmcb->control.exit_info_1 & AVIC_UNACCEL_ACCESS_OFFSET_MASK; switch (offset) { @@ -488,18 +487,17 @@ static int avic_unaccel_trap_write(struct vcpu_svm *svm) return 0; break; case APIC_LDR: - if (avic_handle_ldr_update(&svm->vcpu)) + if (avic_handle_ldr_update(vcpu)) return 0; break; case APIC_DFR: - avic_handle_dfr_update(&svm->vcpu); + avic_handle_dfr_update(vcpu); break; default: break; } - kvm_lapic_reg_write(apic, offset, kvm_lapic_get_reg(apic, offset)); - + kvm_apic_write_nodecode(vcpu, offset); return 1; } @@ -549,7 +547,7 @@ int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu) if (trap) { /* Handling Trap */ WARN_ONCE(!write, "svm: Handling trap read.\n"); - ret = avic_unaccel_trap_write(svm); + ret = avic_unaccel_trap_write(vcpu); } else { /* Handling Fault */ ret = kvm_emulate_instruction(vcpu, 0); -- 2.35.0.263.gb82422642f-goog