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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 5DC62C433B4 for ; Thu, 22 Apr 2021 10:48:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F286760720 for ; Thu, 22 Apr 2021 10:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F286760720 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.115271.219819 (Exim 4.92) (envelope-from ) id 1lZWsx-0002nA-PC; Thu, 22 Apr 2021 10:48:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 115271.219819; Thu, 22 Apr 2021 10:48:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZWsx-0002n3-Ld; Thu, 22 Apr 2021 10:48:39 +0000 Received: by outflank-mailman (input) for mailman id 115271; Thu, 22 Apr 2021 10:48:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZWsw-0002my-Py for xen-devel@lists.xenproject.org; Thu, 22 Apr 2021 10:48:38 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7a221d9f-7979-425b-b972-762f37d95ec1; Thu, 22 Apr 2021 10:48:37 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C11F8B124; Thu, 22 Apr 2021 10:48:36 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a221d9f-7979-425b-b972-762f37d95ec1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1619088516; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wfj3Wq/ZwvGrwAxOSCpJx8Q++ljsC/k1HNHxwv8cBvM=; b=j2r3vMNO21YgTXsVOEbMzNs0SzJ1LjCEBdS28oPOAWRqXnpdeGWglwrfqQ+BsQuscfwDAT uoLPT0DI6tucj0O4QsSU62gWbfYurgkbNJGYe1A0ft39Kxuum13TSQlEyy0+Rcmks6pSJ5 YXveglZfIPBXaRaORGEbV6sY9vPT8rg= Subject: Re: [PATCH v2 15/21] libs/guest: obtain a compatible cpu policy from two input ones To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: Andrew Cooper , Ian Jackson , Wei Liu , Anthony PERARD , xen-devel@lists.xenproject.org References: <20210413140140.73690-1-roger.pau@citrix.com> <20210413140140.73690-16-roger.pau@citrix.com> <391b56d0-bb4d-8d3c-231c-e2e3ad7e2f42@suse.com> From: Jan Beulich Message-ID: Date: Thu, 22 Apr 2021 12:48:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 22.04.2021 12:34, Roger Pau Monné wrote: > On Thu, Apr 22, 2021 at 11:58:45AM +0200, Jan Beulich wrote: >> On 22.04.2021 11:42, Roger Pau Monné wrote: >>> On Wed, Apr 14, 2021 at 03:49:02PM +0200, Jan Beulich wrote: >>>> On 13.04.2021 16:01, Roger Pau Monne wrote: >>>>> @@ -944,3 +945,130 @@ bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t host, >>>>> >>>>> return false; >>>>> } >>>>> + >>>>> +static uint64_t level_msr(unsigned int index, uint64_t val1, uint64_t val2) >>>>> +{ >>>>> + uint64_t val = val1 & val2;; >>>> >>>> For arbitrary MSRs this isn't going to do any good. If only very >>>> specific MSRs are assumed to make it here, I think this wants >>>> commenting on. >>> >>> I've added: "MSRs passed to level_msr are expected to be bitmaps of >>> features" >> >> How does such a comment help? I.e. how does the caller tell which MSRs >> to pass here and which to deal with anyother way? > > All MSRs should be passed to level_msr, but it's handling logic would > need to be expanded to support MSRs that are not feature bitmaps. > > It might be best to restore the previous switch and handle each MSR > specifically? I think so, yes. We need to be very careful with what a possible default case does there, though. >>>>> + xen_cpuid_leaf_t *out) >>>>> +{ >>>>> + *out = (xen_cpuid_leaf_t){ }; >>>>> + >>>>> + switch ( l1->leaf ) >>>>> + { >>>>> + case 0x1: >>>>> + case 0x80000001: >>>>> + out->c = l1->c & l2->c; >>>>> + out->d = l1->d & l2->d; >>>>> + return true; >>>>> + >>>>> + case 0xd: >>>>> + if ( l1->subleaf != 1 ) >>>>> + break; >>>>> + out->a = l1->a & l2->a; >>>>> + return true; >>>> >>>> Could you explain your thinking behind this (a code comment would >>>> likely help)? You effectively discard everything except subleaf 1 >>>> by returning false in that case, don't you? >>> >>> Yes, the intent is to only level the features bitfield found in >>> subleaf 1. >>> >>> I was planning for level_leaf so far in this series to deal with the >>> feature leaves part of the featureset only. I guess you would also >>> like to leverage other parts of the xstate leaf, like the max_size or >>> the supported bits in xss_{low,high}? >> >> The latter is clearly one of the things to consider, yes (alongside >> the respective bits in sub-leaf 0 for XCR0). Sub-leaves > 1 may also >> need dealing with ECX. Yet then again some or all of this may need >> handling elsewhere, not the least because of the unusual handling of >> leaf 0xd in the hypervisor. What gets checked and/or adjusted where >> needs to be settled upon, and then the different parts of code would >> imo better cross-reference each other. > > There's a comment in recalculate_xstate that mentions that Da1 leaf is > the only piece of information preserved, and that everything else is > derived from feature state. I don't think it makes sense to try to > level anything apart from Da1 if it's going to be discarded by > recalculate_xstate anyway? > > I can add a comment here regarding why only Da1 is taken into account > for leveling so far. Yes, this would help. Thanks. Jan