Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp291234pxb; Mon, 7 Feb 2022 11:25:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJydZOGLwI+v5qTv0DqPAIk6MERGmzoDPAxCpYkHoAMBcDaggmMIufCw2msJX/2++/T4uMN7 X-Received: by 2002:a17:907:c14:: with SMTP id ga20mr912284ejc.243.1644261913511; Mon, 07 Feb 2022 11:25:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644261913; cv=none; d=google.com; s=arc-20160816; b=d7SOkaukyDH75ph/xTvSMuDPphbrzeKWgsXj5d8iFjnCIN7biHvNk9Id+exf1AKESN JgBA/efBiNDII2pAM3NDIceuks5fula5vf2+MddqiGiJAJf9LjKIVZgCMvP4gFbtW+Pv +neVfFgXSntRxQfdnw20iaz0fVBOnBl4kx/KME6uiBq/iuaxtEbqoVoNlRYVRkpGLYio MzBl2T/DYbT3N+ig2TADiqV8HLN7ei37fYcPxyIhAIKlS0Iu6Gs2o6G8OHB2dGyZ/HTk 9frUbe2XJU5Dsfqvw9LcJbOapeZVj+DBLpc80X/LhL8WoJA7xBjQBNNZCxK5S+VbcD3R PImA== 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=NkV3Msgch3zFwH89OWlAlvxffB+RDhruYURC7hCf3XE=; b=TbRTNo7FarCrTn8cHPRj2z7dwjWRC7lpEPYhUutq9md+re7mE7H/uGi8pcz7iGVFex 6hwDGaIquLFsxucfqN46rBlws1O1/ziXpPivBZA6D2+/bZkB8SFb+Oltca79p/2N7MGG H8gf4UU2c0DsueKhHaUA0Dp+BwnSbbBqa7VBVbZtD/FH8gWtR0Z5+0auj4nQEvt7n+/W yb9jJA6PusXX/0oqNdjDKyawNXC8UWGO3qU8kj3gEpXip9Deah7CePdOeEU6xXNfviQl /JAT1TEu5AVQxO8vicI7SnOArkZDibKUgAjlrWyK1msUXYZNbZclKaf2uE00xRr/ui/K ELnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Y/9PcR2w"; 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 q8si8628152edd.115.2022.02.07.11.24.49; Mon, 07 Feb 2022 11:25:13 -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="Y/9PcR2w"; 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 S244216AbiBDVnJ (ORCPT + 99 others); Fri, 4 Feb 2022 16:43:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244869AbiBDVmn (ORCPT ); Fri, 4 Feb 2022 16:42:43 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1B6C061762 for ; Fri, 4 Feb 2022 13:42:24 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id u80-20020a627953000000b004c82105f20dso3562458pfc.11 for ; Fri, 04 Feb 2022 13:42:24 -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=NkV3Msgch3zFwH89OWlAlvxffB+RDhruYURC7hCf3XE=; b=Y/9PcR2wxtQOu8vrJPWbtGwHBJoxjOl0ybS/BDNdEgRXAAcUadz2lhRl4+mrbYu8Cq iYrTIUq55RsxkmwX6vHqW+RujwtmEWljWDjPtgnxdlrjxVTnZYmKMEZrOhpctN4jdpS4 cMZ2IMBM1pHffQGgQh69ajLJZlrT2z1SRXag0OtSxHDXDH8W4eo0rQewi71Hso+oFlRf r20xgP7PRdiaDAeuCFWBDxmW/wwGm3seZ6eDfP6RYYG9x9jD4CpBRkfzdP8fcy5ThH5F odZCpjmtKlWAT+srUIYofAFvBWtvFlmin1xtRhDJZdwVZ1PWHVswKGjZcZhtcxtrHdKv 4B7A== 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=NkV3Msgch3zFwH89OWlAlvxffB+RDhruYURC7hCf3XE=; b=s+V9T07NXGTlTtHN8mQvcj6QfznuMONySSpTFemMzyU3WPLl1gSYITOVPI9fD96XNr rXAvmHKtuEHQHefVlChRT7uU9j8c0/Op7dhUTWQBLwso1hdritDG0nUfTj9iiWd0mxc7 RANhjRJ471AQSxjH+zlFK0eMKyV8pfuJKUCw9uaW+/l3vgPcIe+MWjruUUUtYdDdmlKN 1aBfU7Kqg3jTPnYEGU5+lehbRz4osxCpyJHRsNYP+uH58VsykbQmr2WOfxbON3jSlb58 2C5xU8IxRJRRix87eJWy91C8kK3rMXIxdChKM9CIKWdGGu2DpwINzOghhftmGoEV5+08 x8Pw== X-Gm-Message-State: AOAM532R58GFvUuOFsSTf9T3atYNkIFWipnhlMFA5hRBUhc5xGlGQbqU MtGLI29ACjlLmIHls8E3VbkVf7gwV5w= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a62:7a42:: with SMTP id v63mr4994448pfc.61.1644010944420; Fri, 04 Feb 2022 13:42:24 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 4 Feb 2022 21:42:04 +0000 In-Reply-To: <20220204214205.3306634-1-seanjc@google.com> Message-Id: <20220204214205.3306634-11-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 10/11] KVM: x86: Make kvm_lapic_set_reg() a "private" xAPIC helper 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=unavailable 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 Hide the lapic's "raw" write helper inside lapic.c to force non-APIC code to go through proper helpers when modification the vAPIC state. Keep the read helper visible to outsiders for now, refactoring KVM to hide it too is possible, it will just take more work to do so. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 10 ++++++++++ arch/x86/kvm/lapic.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index dd185367a62c..d60eb6251bed 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -68,6 +68,16 @@ static bool lapic_timer_advance_dynamic __read_mostly; /* step-by-step approximation to mitigate fluctuation */ #define LAPIC_TIMER_ADVANCE_ADJUST_STEP 8 +static inline void __kvm_lapic_set_reg(char *regs, int reg_off, u32 val) +{ + *((u32 *) (regs + reg_off)) = val; +} + +static inline void kvm_lapic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val) +{ + __kvm_lapic_set_reg(apic->regs, reg_off, val); +} + static __always_inline u64 __kvm_lapic_get_reg64(char *regs, int reg) { BUILD_BUG_ON(reg != APIC_ICR); diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index e39e7ec5c2b4..4e4f8a22754f 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -161,16 +161,6 @@ static inline u32 kvm_lapic_get_reg(struct kvm_lapic *apic, int reg_off) return __kvm_lapic_get_reg(apic->regs, reg_off); } -static inline void __kvm_lapic_set_reg(char *regs, int reg_off, u32 val) -{ - *((u32 *) (regs + reg_off)) = val; -} - -static inline void kvm_lapic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val) -{ - __kvm_lapic_set_reg(apic->regs, reg_off, val); -} - DECLARE_STATIC_KEY_FALSE(kvm_has_noapic_vcpu); static inline bool lapic_in_kernel(struct kvm_vcpu *vcpu) -- 2.35.0.263.gb82422642f-goog