Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5037885pxv; Wed, 28 Jul 2021 01:20:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySArWqhRQPE9toBpZjxqGzeNNSl94rlgJ+vseogJ0crzO0E2P+HxVRMpCKbTWDYp2YYgyv X-Received: by 2002:a17:906:34d7:: with SMTP id h23mr8422388ejb.293.1627460431134; Wed, 28 Jul 2021 01:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627460431; cv=none; d=google.com; s=arc-20160816; b=fccNqUjTUdL0on9rEZboDMD9/nNIQpXmo8Q1wPxKhXi6NX4rxOKJWPQRLwB07RZY6Y fnCNQYBuKSafIfuu0kUzstOUSMUDDgWCtpDLLARLKnVFfhQp0NIbJh0iDdfkOI2tJBBw Osb8AiKTgpZ46ViRL3uybPVjZuhi+1OlpkvaWPdF0m/uZ6cmWGpbpJG4YQnXTQWzdzcn YKe49Bi9CGYxHNmIPa1V63BSNPqLGg3sXqUukYRkvon19OVhoCSYRhVMRbqnOlDDwIVU VTpIGrOTJ1YHvuDQKhUu7REGID8sqGkX9Ku8lSxdRKKtomGOyJDFYa6cx3Z9GdvVkDWL eF7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=crKmmuF3vSFeLNrZsABSm5kyODHNC6gu4soJ8ICOTvw=; b=bY5blL4N5H0kMj/PGP7flkY7S6K5oTwDR8llIp27Ad06TgVdktsyW7iD4uoHWuYCqW er1kkvWTUmDFuycQWZ9HTecPkSJH3FfY0QcWwBNq3kv1K/7i+YwNBUbEQOYTzQZmOgIi +cAdHe1h1UGTMQk3v8u9AIJbc98QRBJktDWKHX5a+bHQXH1Zh9NHGZhPqby+kRrBpCnI klthCu5bkBupHPjehp2F7A2kdvAKpmEtWqxiiXKHEOwuWuC2HsS3ShqU0wO9YJU91Vri LQ/TY7F/GYU9fRo3zj62jyWRw3ubt0w85Athw7gsgUgzir29obLl9bvbg65dvPzNOlwi 7fmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y0qBJgnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si5245983edd.553.2021.07.28.01.20.08; Wed, 28 Jul 2021 01:20:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y0qBJgnE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235081AbhG1ISo (ORCPT + 99 others); Wed, 28 Jul 2021 04:18:44 -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-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