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=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B366CC4338F for ; Wed, 28 Jul 2021 08:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9520B60F41 for ; Wed, 28 Jul 2021 08:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbhG1ISr (ORCPT ); Wed, 28 Jul 2021 04:18:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36809 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234604AbhG1ISj (ORCPT ); Wed, 28 Jul 2021 04:18:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627460318; 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: in-reply-to:in-reply-to:references:references; bh=crKmmuF3vSFeLNrZsABSm5kyODHNC6gu4soJ8ICOTvw=; b=Y0qBJgnEXvh61l+Zk6jYrHPi9S+/aw3WwghmYkQGSTu86Fwt5HSx1oUgI3V85AE7A7GSmv APAdERDhD5gLJliAdbFhIoz7G/pZgzNl7oV7iaL2iNI7GwUbysRGdR+ZtPhw0XsPMYmMN7 C4lmT2TI2oDkCbAU5kEUDUOldmxgGU4= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-501-kf3q1KqRMk-mdolc6-YdBA-1; Wed, 28 Jul 2021 04:18:36 -0400 X-MC-Unique: kf3q1KqRMk-mdolc6-YdBA-1 Received: by mail-ed1-f72.google.com with SMTP id d12-20020a50fe8c0000b02903a4b519b413so877023edt.9 for ; Wed, 28 Jul 2021 01:18:36 -0700 (PDT) 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:in-reply-to:references:date :message-id:mime-version; bh=crKmmuF3vSFeLNrZsABSm5kyODHNC6gu4soJ8ICOTvw=; b=QarUD8wI6p6mj6TFAD1OOjMD0kRez370G35IVN6tc6btY/akN6xSBT9hc9pZEqBplA OaqoP48LWynVwsdU4JQk/kA4t5f3AolZsu89ZZF3xuiI418T0Ga203ddh/z04fUaXGOa hMqJ6JMRoXGAcfktZjXK+U/Z414wOQQVTNq7Um+qEEbS7yJUoRaWrT/WUal++kkByIN8 ScyAeb3i/lbmT1GOupKwDGg7I2gGXWPrZ36C6eVgpg6MKmY6uqJ96iQuhseyO6ETUwGI RgxH7sqWW6+hKRGfn4bXsQ+o2Y3frwPUH0SIEaI5oe22CTBUwZapu1p42s1bp6D8EAKJ xPxg== X-Gm-Message-State: AOAM531YTXEj8h4cOR5LvqVeJEZOo4VFqc5cYLRE2pZecdslUhpErVm1 OmBRyGZNWo0kbnLdEjneV+Illb5OYFAK7f+ncXkQn+HNv43TlLyb3Xocpi6Gm2hw1bQmkTZQGJ9 LnAGc5qN6LOQfQOyX9mkI4J0b X-Received: by 2002:a50:a456:: with SMTP id v22mr32224211edb.333.1627460315724; Wed, 28 Jul 2021 01:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRbmAu4lAhEfewYa9Hmlor8TFe5yKDcZw3jUIl3o2oxP/V0Eq5Q+BPPoJfCrH+1EnY8l1sBw== X-Received: by 2002:a50:a456:: with SMTP id v22mr32224202edb.333.1627460315603; Wed, 28 Jul 2021 01:18:35 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id h1sm1742941eji.46.2021.07.28.01.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 01:18:35 -0700 (PDT) From: Vitaly Kuznetsov To: Suleiman Souhlal Cc: ssouhlal@FreeBSD.org, joelaf@google.com, senozhatsky@chromium.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Suleiman Souhlal , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: Re: [RFC PATCH 2/2] kvm,x86: Report preempt_count to host. In-Reply-To: <20210728073700.120449-3-suleiman@google.com> References: <20210728073700.120449-1-suleiman@google.com> <20210728073700.120449-3-suleiman@google.com> Date: Wed, 28 Jul 2021 10:18:33 +0200 Message-ID: <87tuke6ecm.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Suleiman Souhlal writes: > When KVM_PREEMPT_COUNT_REPORTING is enabled, the host can use > preempt_count to determine if the guest is in a critical section, > if it also has CONFIG_KVM_HETEROGENEOUS_RT enabled, in order to > use heterogeneous RT VCPU configurations. > > Signed-off-by: Suleiman Souhlal > --- > arch/x86/Kconfig | 11 +++++++++++ > arch/x86/kernel/kvm.c | 10 ++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 49270655e827..d8b62789df57 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -846,6 +846,17 @@ config PARAVIRT_TIME_ACCOUNTING > config PARAVIRT_CLOCK > bool > > +config KVM_PREEMPT_COUNT_REPORTING > + bool "KVM preempt_count reporting to the host" > + depends on KVM_GUEST && PREEMPT_COUNT > + default n > + help > + Select this option to enable KVM preempt_count reporting to the host, > + which can be useful in cases where some VCPUs are RT and the rest > + aren't. > + > + If in doubt, say N here. > + > config JAILHOUSE_GUEST > bool "Jailhouse non-root cell support" > depends on X86_64 && PCI > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index a26643dc6bd6..7ec53ea3f979 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -363,6 +363,16 @@ static void kvm_guest_cpu_init(void) > > if (has_steal_clock) > kvm_register_steal_time(); > + > +#ifdef CONFIG_KVM_PREEMPT_COUNT_REPORTING > + if (kvm_para_has_feature(KVM_FEATURE_PREEMPT_COUNT)) { > + unsigned long pa; > + > + pa = slow_virt_to_phys(this_cpu_ptr(&__preempt_count)) | > + KVM_MSR_ENABLED; > + wrmsrl(MSR_KVM_PREEMPT_COUNT, pa); > + } > +#endif > } Please also disable the feature in kvm_guest_cpu_offline() as e.g. upon kexec the memory address looses its meaning. > > static void kvm_pv_disable_apf(void) -- Vitaly