Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1783901rwi; Thu, 3 Nov 2022 09:02:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jHChBktBFYhAogPwXv+2eRgRO20++1PzxLc3eMThHISkZWutWwWgY3NjCyd1c8Ea+hZ4a X-Received: by 2002:a17:906:5dda:b0:78d:e7d2:7499 with SMTP id p26-20020a1709065dda00b0078de7d27499mr29865663ejv.588.1667491364534; Thu, 03 Nov 2022 09:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667491364; cv=none; d=google.com; s=arc-20160816; b=iUG3NPcoHTWnJoZji6oZrgGaV36A7/TVi2RlbpBvO6Ez/cNTSxpgEMfNvpQOu5zmBj OiLpnzTjrNHIGwJRMqYAAFatFXETQehBBGAaZfLtlyRdEPyGawsNnHlkW8yE8h6XJTix KMzukQw359AsILeSpwkfon4FkLnHlYvyIZuHrxLKgMDQFVAQmWN1myd+w1Xe40YtL+fk VWEr/kqG6wCk3VuNgKwLef98xo1dRkJl+LoE23XMJHvcs2Uw3YlO0TJylSPoVVJTRguV bS0OpCLR0mTpwTn6oWLgetvk/EzYw7rhYcWL1IfDLI5xW8gWQejlaahZSMCVvrISk4Ky DrRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=B+nihbaQ/cnO5MxH1a/EyI4K5Rm5LqSQzIW/65Ge7UA=; b=aadHWxL+tTLJdmrQjxaIZPrf6ql29fN+ebQDIHMoMefE1A3C+VXTcwG4KHvznwJRxJ PUgtl8j64vo4yNivGSr9xrFt5PXLKFcwcVMwon9aIqA8CKiztlA0HiJWMYrlWETG/eCJ ihwL0TVFIpHqz2OdrWSED/IRplhO+quhkD+KCrxJ5YFJjnOMADfwjDxrIYb0xM2lARXa JVfC/DeVDAI7gbg+J2/M9zoXP1LjZnQFeCk4RlR6fWL0nqM7ApO74nII0MiO1iaWNmNs 6ADTN6r/tbPF7xzjZBkPVHoDxXxd+3kpHsGPkhVFvRyNMlom8iGDckCaeHR6CFrCFNnc SE/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cM3AdOan; 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 nb20-20020a1709071c9400b00791a2a7e578si1870345ejc.641.2022.11.03.09.02.01; Thu, 03 Nov 2022 09:02:44 -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=cM3AdOan; 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 S231354AbiKCPYQ (ORCPT + 97 others); Thu, 3 Nov 2022 11:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbiKCPYM (ORCPT ); Thu, 3 Nov 2022 11:24:12 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DF0515827; Thu, 3 Nov 2022 08:24:12 -0700 (PDT) Received: from anrayabh-desk.corp.microsoft.com (unknown [167.220.238.193]) by linux.microsoft.com (Postfix) with ESMTPSA id B9FFF20C3338; Thu, 3 Nov 2022 08:24:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B9FFF20C3338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667489051; bh=B+nihbaQ/cnO5MxH1a/EyI4K5Rm5LqSQzIW/65Ge7UA=; h=From:To:Cc:Subject:Date:From; b=cM3AdOan+ajzCyLXooGLGKHwUEZIAU5YSidnAn8uAj9qdv3Ry2lJzGgf6ttx8JbTS MChjTJhNln27fqvWY8o9qk/GZg0h3Pt2EMb/ZIpvC28LjcWjO9TDWAkd2BnOTwoMeb BmpVrkawEqJ/kO2M6/zC7PcA0OozgXcUTkanBgfs= From: Anirudh Rayabharam To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Daniel Lezcano , Thomas Gleixner Cc: mail@anirudhrb.com, kumarpraveen@linux.microsoft.com, Anirudh Rayabharam , Michael Kelley , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN Date: Thu, 3 Nov 2022 20:53:37 +0530 Message-Id: <20221103152338.2926983-1-anrayabh@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 __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