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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 8EB3EC43461 for ; Thu, 15 Apr 2021 22:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7194861131 for ; Thu, 15 Apr 2021 22:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237495AbhDOWWQ (ORCPT ); Thu, 15 Apr 2021 18:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237401AbhDOWWA (ORCPT ); Thu, 15 Apr 2021 18:22:00 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E0EC061763 for ; Thu, 15 Apr 2021 15:21:34 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v2so3937482ybc.17 for ; Thu, 15 Apr 2021 15:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=5bZDkTOmF30k3ylXE7mjWEUF6Se+XKGXeTtOG326tls=; b=u8/EHms+P5QHbtTJ6SsWhwk29xFysKHQdf/9xINwhk2Wxp21WIFSsVeUCy33wKtjFy lUmj0nJPEi1n3Oh0A/Bgumm6PBfeRQ6rZ6U/hC52JnbgBrzx6Jwpq61xXK+tFBYn07IA kAc09ehAkcpVLpAu8SPSKStvPEd9Ubx9twCwkgnSJZd30C8OLAntIF86x0Zdvht71NN5 s84XV5pqBHrcqFv2Av1nDsm/Dn5rp/O/+/cSldZguahj7hUC9TWg1fG2Nd5xxJ9MgVCK hmjkzhRlEIteP178WSGuZ8PcLY0tZW6hKtnGHn1ErP7Lmb892CbNGFt4X8R+qosWioiv 3SSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=5bZDkTOmF30k3ylXE7mjWEUF6Se+XKGXeTtOG326tls=; b=MDgrBykJziuHqBttvssIOAO4lBsRJlV2cl1LLXT56o/sHyK0I9Fb1iTO++a/kzpA/n tN1vQbAyRPOJlK7FC8MiTJa1AxL7S6smyT5gPdvwjLt7HMylHFbHKJYKOB/YLiKjPEGl ISIBuKSw7xUpcrVrlFWHu1mrWOrbOKWEX6ajUoJn1iZq1jLrgHmLCxgZIstZx5KEbu+s 3Gmb8J2Ab1VF5tZvZF/Lm2I7zjuofu8utp5/p/jzeO9DwqJ32m+RtJP4UQh1+Md2GACS v8Mlu08kELf/b2fLMp1DIGdYl7MpGCV9IYFG789gSlV/oiLrqrQDsKVw3QngFm5z5+Ri HTTg== X-Gm-Message-State: AOAM5333Jo34hQSQKBpBmglWKUWOLRM1emQStIR6DezgF4utUxXpFy0T WvuykB7y5MFw6Orbwz02oj8pLvrJlig= X-Google-Smtp-Source: ABdhPJzkSOmVcTYZbMZ5mFcI1gbLLhi87LjETeJ5cPYgxWeheNNd0DFYGFGeWJlxcCCk0oPTkVNLc+BLJCU= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:6c93:ada0:6bbf:e7db]) (user=seanjc job=sendgmr) by 2002:a25:f80e:: with SMTP id u14mr7738720ybd.428.1618525294052; Thu, 15 Apr 2021 15:21:34 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 15 Apr 2021 15:21:06 -0700 In-Reply-To: <20210415222106.1643837-1-seanjc@google.com> Message-Id: <20210415222106.1643837-10-seanjc@google.com> Mime-Version: 1.0 References: <20210415222106.1643837-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog Subject: [PATCH v3 9/9] KVM: Move instrumentation-safe annotations for enter/exit to x86 code 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, Thomas Gleixner , Michael Tokarev , Christian Borntraeger Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop the instrumentation_{begin,end}() annonations from the common KVM guest enter/exit helpers, and massage the x86 code as needed to preserve the necessary annotations. x86 is the only architecture whose transition flow is tagged as noinstr, and more specifically, it is the only architecture for which instrumentation_{begin,end}() can be non-empty. No other architecture supports CONFIG_STACK_VALIDATION=y, and s390 is the only other architecture that support CONFIG_DEBUG_ENTRY=y. For instrumentation annontations to be meaningful, both aformentioned configs must be enabled. Letting x86 deal with the annotations avoids unnecessary nops by squashing back-to-back instrumention-safe sequences. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.h | 4 ++-- include/linux/kvm_host.h | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 285953e81777..b17857ac540b 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -25,9 +25,9 @@ static __always_inline void kvm_guest_enter_irqoff(void) instrumentation_begin(); trace_hardirqs_on_prepare(); lockdep_hardirqs_on_prepare(CALLER_ADDR0); - instrumentation_end(); - guest_enter_irqoff(); + instrumentation_end(); + lockdep_hardirqs_on(CALLER_ADDR0); } diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 444d5f0225cb..e5eb64019f47 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -339,9 +339,7 @@ static __always_inline void guest_enter_irqoff(void) * This is running in ioctl context so its safe to assume that it's the * stime pending cputime to flush. */ - instrumentation_begin(); vtime_account_guest_enter(); - instrumentation_end(); /* * KVM does not hold any references to rcu protected data when it @@ -351,21 +349,16 @@ static __always_inline void guest_enter_irqoff(void) * one time slice). Lets treat guest mode as quiescent state, just like * we do with user-mode execution. */ - if (!context_tracking_guest_enter_irqoff()) { - instrumentation_begin(); + if (!context_tracking_guest_enter_irqoff()) rcu_virt_note_context_switch(smp_processor_id()); - instrumentation_end(); - } } static __always_inline void guest_exit_irqoff(void) { context_tracking_guest_exit_irqoff(); - instrumentation_begin(); /* Flush the guest cputime we spent on the guest */ vtime_account_guest_exit(); - instrumentation_end(); } static inline void guest_exit(void) -- 2.31.1.368.gbe11c130af-goog