Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1811774rwi; Thu, 3 Nov 2022 09:18:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57TOQoNdDgSK32jCuKxeDwv4EsSdNvv6rMA/FtEI/xZIj1zvCJDjjuYwrPmzJBZ7x5raY7 X-Received: by 2002:a17:907:9602:b0:780:8c9f:f99a with SMTP id gb2-20020a170907960200b007808c9ff99amr30141055ejc.465.1667492297282; Thu, 03 Nov 2022 09:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667492297; cv=none; d=google.com; s=arc-20160816; b=HF4L0JIOMkBMyfMU5mVyg7BKzZ8lNz8hG9uXWGtIrHunKdEm3VnbSD4Fe/XGdoA8W4 0TVEB3vgKP5WK2KByPZIIifiiBHGbXXkhEk96IXD2bOVxYSzZxabjjl3SSrMO4HCiVjQ Ryq69pyFBWk7czAsZONpb2WpmhLFo3mIpvVSJ1gAc+L8cjiHIIu4bgDwkGIeCSmAtSu8 VgNN8DqRxXf6Sg3T/XazEYVo+yMxp9RdnU16dXZUy2TpJ4LbjRVJ9MaH9sBlpDZs6cow wIpJv/r8GyA4cp6NaAPBcsYdi8ory6hkpOCVYUrV9N/fhJpfiu/dIFE6YRHjDPwFpl6c jPAw== 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; bh=39Wq79lyITbkFUX8I3WqtfNpU9PWy7SSBeSmagRdmwc=; b=TqZTLNsmuWDjiC/U2+CTGK6X1FJlNZpUj9JUVSVwt68/LQ2DREHixNim9s9fP4P7// SAqWF8psrWcuvKChlOqLLM+/Rses0MM6aKSSFgamzbzNOOh+HT/4IimIGZE5L3WAo1B1 tRz+RFXAa/Ie6XF+ad1IvWQv6m9aO++h35eDCgO+Dj25tPDHyBM9989TJYK3b4a5LIC6 SrzPczNL0h6oVJMdipetrEhE9zY4odCUEqS/ZJRlJknC7GjU5LJ+BXe56WeI8HWT93JV GLNTwowgxl9pS73xi9NhEDHVS/f+TMj5Oasz6mX3iqHH+lnMh+hOKABxxmfL2UR6cqwx nBCg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go31-20020a1709070d9f00b0077547abf08fsi2055580ejc.169.2022.11.03.09.17.53; Thu, 03 Nov 2022 09:18:17 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbiKCPsn (ORCPT + 98 others); Thu, 3 Nov 2022 11:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbiKCPsg (ORCPT ); Thu, 3 Nov 2022 11:48:36 -0400 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D0664D1; Thu, 3 Nov 2022 08:48:36 -0700 (PDT) Received: by mail-wr1-f44.google.com with SMTP id h9so3462838wrt.0; Thu, 03 Nov 2022 08:48:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=39Wq79lyITbkFUX8I3WqtfNpU9PWy7SSBeSmagRdmwc=; b=lGc0RW+F45Dx4VwI4Hh+cJtFjAg/aIehzH/gh3PsPXxFWC3R7FOUnh6dyv5WwspLT7 jRflXjqj0RFm7Tdql1mgbnN0A9HQ7tGeLI/CruXg8Ug2AWxn/62DPWkN6CpNQk6q+K2V 5ZFGT6PA8v1wGIwj5YfnssxXJCGSWS9GgA/buuFdi2X0w0++r3LnDIpoD1EBZhHmM9EL UAF2v0+Huj+xCcYLbg5OdQmznc2bUm/gllQ3TEip8IfI12/79xTgMboSqeceHwK/+OPL C9HOW8GT3DTRnEx76fxy7nE9nqoCbi7R1wPognEkL1i09Eu87Eu2XFIJ8jjFBX3s3w4L VEyg== X-Gm-Message-State: ACrzQf1GOIE31z+GLUeNdcGqZD5CXdVNiTVOJ2z+G8akxT5+/KCJwVBw r010lIrhKarAayvZ5foMriQ5YUfGYzA= X-Received: by 2002:a5d:6ac7:0:b0:236:b281:150 with SMTP id u7-20020a5d6ac7000000b00236b2810150mr18593143wrw.29.1667490514597; Thu, 03 Nov 2022 08:48:34 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id o3-20020a05600c510300b003b3307fb98fsm314938wms.24.2022.11.03.08.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:48:34 -0700 (PDT) Date: Thu, 3 Nov 2022 15:48:24 +0000 From: Wei Liu To: "Michael Kelley (LINUX)" Cc: Anirudh Rayabharam , KY Srinivasan , Haiyang Zhang , Wei Liu , Dexuan Cui , Daniel Lezcano , Thomas Gleixner , "mail@anirudhrb.com" , "kumarpraveen@linux.microsoft.com" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN Message-ID: References: <20221103152338.2926983-1-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=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 03:34:23PM +0000, Michael Kelley (LINUX) wrote: > From: Anirudh Rayabharam Sent: Thursday, November 3, 2022 8:24 AM > > > > __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. The PFN for the > > TSC page always needs to be a Hyper-V PFN. > > > > Use HVPFN_DOWN() to calculate the PFN of the TSC page from the physical > > address. > > > > Reported-by: Michael Kelley (LINUX) > > Signed-off-by: Anirudh Rayabharam > > --- > > drivers/clocksource/hyperv_timer.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c > > index 11332c82d1af..18de1f439ffd 100644 > > --- a/drivers/clocksource/hyperv_timer.c > > +++ b/drivers/clocksource/hyperv_timer.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -412,7 +413,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg) > > /* Re-enable the TSC page */ > > tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > tsc_msr.enable = 1; > > - tsc_msr.pfn = __phys_to_pfn(phys_addr); > > + tsc_msr.pfn = HVPFN_DOWN(phys_addr); > > hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); > > } > > > > @@ -532,7 +533,7 @@ static bool __init hv_init_tsc_clocksource(void) > > */ > > tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); > > tsc_msr.enable = 1; > > - tsc_msr.pfn = __phys_to_pfn(phys_addr); > > + tsc_msr.pfn = HVPFN_DOWN(phys_addr); > > hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); > > > > clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100); > > -- > > 2.34.1 > > Reviewed-by: Michael Kelley Thank you both for the quick turnaround. I will just squash this patch into the previous one.