Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1749619rwi; Thu, 3 Nov 2022 08:39:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71V7Sy+2plxSwYFy4Gox4XbKAa9BP6Pp2x5dj2IfKtTLe9vaUmhEbCiu4ewZ/KHbYPb8hp X-Received: by 2002:a05:6402:5159:b0:462:3e9f:a0a4 with SMTP id n25-20020a056402515900b004623e9fa0a4mr30175029edd.313.1667489985662; Thu, 03 Nov 2022 08:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667489985; cv=none; d=google.com; s=arc-20160816; b=JpQMmjCCtF/c60DLjZ62V4o0EqAckZu6uUDkxJcJPYzrpXV9zNvi86gySF5ptGPe0o 2rDFNKzNqwx+nULuHu0tdXk3KCqqWQtQBLHA5qTaxDua2M96Q8Nw5piweOfVCNY3bzex wPnD+17EUh7TK4L46L6xOVosY+SVZq3kcUkGWXqvKZpMwdewnp1pTk+Kf56NMZcfOmw5 O1HNYqnUL9uWic3BaU0wB9k59mFpwjPjyC3JCHqUzrSKs5hNB8iqEuUdp47dXCJ4solM 2O5+sqX0VXa+xUxn6bePaQzRHjnvn92MvKfkl7ynmoeQlUfgXSZNTusG02zo0TAYXsOg voYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=LVBwdOCgh5S6moCYBOoLpAcgiJqiRXPqQN4nBFQUFc4=; b=UAtQIxNo/2hA2LZn4JqlS3UOC9zoENr5lNlRq4uwdAok90QH/GmMB+4N7ty7O+Yh1K 1ahrcj7y9HtZSmMFtC9RfejMcCg+D8kacEKf+gqwKUT1Y+e1Zh95tyL6zGtL9NBAQCwA ub78kj2aMW/H7l4AVYC+73efGei69vk85gdyDxVw1lbRpMHSObkz1xge1HITA2rChekf LCAEdujF723EteZ1XyxxGfdKmnUBNNSa6iTDAmIyPx13NlIqlPcFblLs673SCEVx05T2 +nsLBowA7DT8xutf5aQyzZFRrlMUnl0cgurrT7hxahL6td6AQWqJ1l0CHbq+wBUIdSKq 5oXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EKj6uG4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh9-20020a1709076e8900b007ae0211844dsi1591853ejc.937.2022.11.03.08.39.21; Thu, 03 Nov 2022 08:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EKj6uG4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbiKCPbS (ORCPT + 97 others); Thu, 3 Nov 2022 11:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbiKCPao (ORCPT ); Thu, 3 Nov 2022 11:30:44 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8E151CB3C; Thu, 3 Nov 2022 08:30:25 -0700 (PDT) Received: from anrayabh-desk (unknown [167.220.238.193]) by linux.microsoft.com (Postfix) with ESMTPSA id A3C65205DA30; Thu, 3 Nov 2022 08:30:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A3C65205DA30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667489425; bh=LVBwdOCgh5S6moCYBOoLpAcgiJqiRXPqQN4nBFQUFc4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EKj6uG4ALhiUoBACqTyMJgoglFkzdtbwaHbNPafkQqBy8VihwsnkHXpXGBqq/BEVU +XbhLL+Jd3q/81THSkWW0JFeg1/0S5/cmK/uiA59yi9HCD5xyw7OYEAWlR38ysRRU5 N897vK30B2PQdT0BPVi5a5sfNc/n/SMoqoR4VhAQ= Date: Thu, 3 Nov 2022 21:00:15 +0530 From: Anirudh Rayabharam To: Wei Liu Cc: "Michael Kelley (LINUX)" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "daniel.lezcano@linaro.org" , Arnd Bergmann , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , "stanislav.kinsburskiy@gmail.com" , "kumarpraveen@linux.microsoft.com" , "mail@anirudhrb.com" Subject: Re: [PATCH v2 1/2] clocksource/drivers/hyperv: add data structure for reference TSC MSR Message-ID: References: <20221027095729.1676394-1-anrayabh@linux.microsoft.com> <20221027095729.1676394-2-anrayabh@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 03, 2022 at 02:24:05PM +0000, Wei Liu wrote: > On Wed, Nov 02, 2022 at 08:33:31PM +0000, Michael Kelley (LINUX) wrote: > > From: Michael Kelley (LINUX) Sent: Thursday, October 27, 2022 6:43 AM > > > From: Anirudh Rayabharam Sent: Thursday, > > > October 27, 2022 2:57 AM > > > > > > > > Add a data structure to represent the reference TSC MSR similar to > > > > other MSRs. This simplifies the code for updating the MSR. > > > > > > > > Signed-off-by: Anirudh Rayabharam > > > > --- > > > > drivers/clocksource/hyperv_timer.c | 28 ++++++++++++++-------------- > > > > include/asm-generic/hyperv-tlfs.h | 9 +++++++++ > > > > 2 files changed, 23 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/drivers/clocksource/hyperv_timer.c > > > b/drivers/clocksource/hyperv_timer.c > > > > index bb47610bbd1c..11332c82d1af 100644 > > > > --- a/drivers/clocksource/hyperv_timer.c > > > > +++ b/drivers/clocksource/hyperv_timer.c > > > > @@ -395,25 +395,25 @@ static u64 notrace read_hv_sched_clock_tsc(void) > > > > > > > > static void suspend_hv_clock_tsc(struct clocksource *arg) > > > > { > > > > - u64 tsc_msr; > > > > + union hv_reference_tsc_msr tsc_msr; > > > > > > > > /* Disable the TSC page */ > > > > - tsc_msr = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > > > - tsc_msr &= ~BIT_ULL(0); > > > > - hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr); > > > > + tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > > > + tsc_msr.enable = 0; > > > > + hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); > > > > } > > > > > > > > > > > > static void resume_hv_clock_tsc(struct clocksource *arg) > > > > { > > > > phys_addr_t phys_addr = virt_to_phys(&tsc_pg); > > > > - u64 tsc_msr; > > > > + union hv_reference_tsc_msr tsc_msr; > > > > > > > > /* Re-enable the TSC page */ > > > > - tsc_msr = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > > > - tsc_msr &= GENMASK_ULL(11, 0); > > > > - tsc_msr |= BIT_ULL(0) | (u64)phys_addr; > > > > - hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr); > > > > + tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > > > + tsc_msr.enable = 1; > > > > + tsc_msr.pfn = __phys_to_pfn(phys_addr); > > > > My previous review missed a problem here (and in the similar line below). > > __phys_to_pfn() will return a PFN based on the guest page size, which might > > be different from Hyper-V's page size that is always 4K. This needs to be a > > Hyper-V PFN, and we have virt_to_hvpfn() available to do just that, assuming > > that function is safe to use here and in the case below. > > Anirudh, please take a look. Just sent a fix for this using HVPFN_DOWN() which looks safe to use here. Thanks, Anirudh. > > I'm holding off sending hyperv-fixes to Linus for now. > > Thanks, > Wei.