Received: by 10.192.165.156 with SMTP id m28csp762613imm; Fri, 13 Apr 2018 07:25:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+H07rqSWt/TU0Bsq8bLkz/+Ok8M4FScFEt6Xr1wHVo+7ScbYNvwTR4PUG58LFB6NJKLtmo X-Received: by 10.98.159.129 with SMTP id v1mr11594949pfk.25.1523629554047; Fri, 13 Apr 2018 07:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523629554; cv=none; d=google.com; s=arc-20160816; b=E2hMmxhqrDy0ppJgjZHRZVXK/z09mL+YOznKPkbxGW7HEhNjaQIzPkehGM+1+DNgc9 Izza3UGp9M9Zwplk56mgIGqugqmxu9P3LdnqBF4EJg95MBRzftKWrtmC8OF60BMfg3Q9 dmMi6D7QdRul6bVIRTxYKGuWNDIk9rO+++L5VDr1tRoZxXDBoshKgaCc/QFS6z4cFx5B zAfEtfYlonq6O8jWoscssn5T25Korw8+6Xf19bny2VUjVBt+9aSjCsFn6lrYWaglk37F xB1iiZ31aNiQl1qpmWPuaQHg+EVAEkigZcerwaUwi0LvCGhDx1TsEA6RAG2FV6W5LFlH wBpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=/2NrkNO8lPkP0x6+azrXXtFKd+AreJlZD2Xj9IdTdqc=; b=ScuKlJay2SbP5hMX7UqTL4MjSOevNyjqS8MzkYvDO0UTWHKD0HXkouO3vYrkH6BhK/ 6oqOaZEQECwq47yAGYG/Gnbj3famhIrIbSfCt9orfVvFUmMvQC365q/ktsFV4kO+W42n KhaqJ94TUOxDPwNc4JFf5+4qzMz6DFse4O2fazD2C/a37oybvOB9hcU6eBNua79sT/0f hUUZm77j6qGsy9Z/JtOauKO/peugnUQIZU2v9d/YpFMM7sdPl3Cy5QLSN8YiNLhp3r4L RJnSTWfa5XznHQN7wZJmxIrrsQqI/da7m7iz2UBm/J0j8j0soIeXZWuoiTPCxqhXvGyC NCUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si5482645pld.255.2018.04.13.07.25.39; Fri, 13 Apr 2018 07:25:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbeDMOXn (ORCPT + 99 others); Fri, 13 Apr 2018 10:23:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52396 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752093AbeDMOXl (ORCPT ); Fri, 13 Apr 2018 10:23:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEA154040856; Fri, 13 Apr 2018 14:23:40 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC68110F1BF5; Fri, 13 Apr 2018 14:23:38 +0000 (UTC) From: Vitaly Kuznetsov To: Paolo Bonzini Cc: kvm@vger.kernel.org, x86@kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley \(EOSG\)" , Mohammed Gamal , Cathy Avery , Tianyu Lan , linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: x86: VMX: hyper-v: Enlightened MSR-Bitmap support References: <20180412152508.27617-1-vkuznets@redhat.com> Date: Fri, 13 Apr 2018 16:23:37 +0200 In-Reply-To: (Paolo Bonzini's message of "Fri, 13 Apr 2018 15:52:30 +0200") Message-ID: <87muy7423a.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 13 Apr 2018 14:23:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 13 Apr 2018 14:23:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paolo Bonzini writes: > On 12/04/2018 17:25, Vitaly Kuznetsov wrote: >> @@ -5335,6 +5353,9 @@ static void __always_inline vmx_disable_intercept_for_msr(unsigned long *msr_bit >> if (!cpu_has_vmx_msr_bitmap()) >> return; >> >> + if (static_branch_unlikely(&enable_emsr_bitmap)) >> + evmcs_touch_msr_bitmap(); >> + >> /* >> * See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals >> * have the write-low and read-high bitmap offsets the wrong way round. >> @@ -5370,6 +5391,9 @@ static void __always_inline vmx_enable_intercept_for_msr(unsigned long *msr_bitm >> if (!cpu_has_vmx_msr_bitmap()) >> return; >> >> + if (static_branch_unlikely(&enable_emsr_bitmap)) >> + evmcs_touch_msr_bitmap(); > > I'm not sure about the "unlikely". Can you just check current_evmcs > instead (dropping the static key completely)? current_evmcs is just a cast: (struct hv_enlightened_vmcs *)this_cpu_read(current_vmcs) so it is always not NULL here :-) We need to check enable_evmcs static key first. Getting rid of the newly added enable_emsr_bitmap is, of course, possible. (Actually, we only call vmx_{dis,en}able_intercept_for_msr in the very beginning of vCPUs life so this is not a hotpath and likeliness doesn't really matter). Will do v2 without the static key, thanks! > > The function, also, is small enough that inlining should be beneficial. > > Paolo -- Vitaly