From patchwork Thu Nov 3 15:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anirudh Rayabharam X-Patchwork-Id: 14947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp604018wru; Thu, 3 Nov 2022 08:33:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+wZK7FrQ8TWm/zut08OaqO7raJMoE7aIuTNLKRPQiZYIfF0I1kCnivs6hnk62E44q3gAJ X-Received: by 2002:a05:6a00:b82:b0:56c:d5bf:1019 with SMTP id g2-20020a056a000b8200b0056cd5bf1019mr30666918pfj.72.1667489639565; Thu, 03 Nov 2022 08:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667489639; cv=none; d=google.com; s=arc-20160816; b=MRm1TyCRn9WpeRSiZpZYRVoTWYLjBiYGBVyLkPwoX2NxjbRrefKeWvmNKLe7fEsdk4 ZA10QRL/yXwj7EkdkxRxLzbV/9scvE/O3gTn8n8eHdA9KT2ViXyoQWQFxSKNqsBt1euz UrnEs5AVTbk8D5QXzMIpQplBFmHR9ZrEGfOVKgt4RtfFetys5PRRjnjs+hb66OMOmciP J+vKx98yIyEl+SQR4noOCW4bEhqjxWh8+5qUgP63AciVMq+n6UOdXYqgudVSdI3S4W/F CpzQIlY5aHcrV3Wve3sTp524x/d7YOK8b1uRI+UJ7UEjI/3GE8b2BZUVWYqRftXf2gC+ 1iXg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a17090a8d0700b0021305ca5933si231331pjo.42.2022.11.03.08.33.44; Thu, 03 Nov 2022 08:33:59 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748489616485489108?= X-GMAIL-MSGID: =?utf-8?q?1748489616485489108?= __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 Reviewed-by: Michael Kelley --- 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);