Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1723077rwi; Thu, 3 Nov 2022 08:22:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rFzRB8CFHe14ayFj6b6ijHhEbUJebrD9nPWcVj7dRzB8kbPGP8aS6R9QE0lWgqmZ9tv9M X-Received: by 2002:a63:de0e:0:b0:46f:23c6:e7d9 with SMTP id f14-20020a63de0e000000b0046f23c6e7d9mr26381759pgg.68.1667488969634; Thu, 03 Nov 2022 08:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667488969; cv=none; d=google.com; s=arc-20160816; b=tM1GFuIIyXJ50qF2jq5bJQfIFNvbZOcPklDhzA0NE80OBxWAU35YyBaVKiWDneDZgG KqEgsnOmc5876jStAsKOhOLtaM8VvknIsNObDiwNtdYRj+FzbdLrYD8I9N3es8vtOjkR RyzvmJY+skrfBUiIcMc4ciPrLj+pQBv3eBkAj1A1GXlvJ1QKeWkiGZ2ycK8lLYOOUNWg 4oJ3nnXAC3GNalhUX34Y4cJuc3iG7CE/AVvjenwDs2/yPT//1qe7G/uSI20hMF0tX8Gb AFStDy14AymrGwGvWanBxBiAuqR3NLbFRHW1s4bqUTU0wDp3j1ICjHHiWpfaqzFD4ALr dsKQ== 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=X1LT03bLiRuIHRMNZ/VBHuLAuNEKFfSIdBpGFc2+9sA=; b=EE8LUm73TfyF0c2kAUu6tvx/w2DCRumUPB2DSyNPZz4tCzWdEgBQ7R6vZfQjjVsrTb FeUHXsUja5yXYN+NfGN0MF6N6J3GNTWUCIxikxuCels8rJ9g9MfD+n1/m2h8FiRxK+S4 uRThKO6HEMoeJGeae/g7XCylha9PTelkvueShtQ0rblthCxJ7FDLQUngnMgBUzUSv/xi /abo09XHDSN5em2UrqhaUlvb7NhtNGm/P/SK2O2vwA440tzagcqYU93j0J0YVjCtoGCq vjYHKg8Y5oL+Cncl7JX/OgNkz0XgqH/W70tIIUP5eAKFp3PO+6npuxGEyufWP90rCVZL laoQ== 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 y3-20020a17090abd0300b0020b042ed0e1si150472pjr.154.2022.11.03.08.22.25; Thu, 03 Nov 2022 08:22:49 -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 S231273AbiKCOYT (ORCPT + 97 others); Thu, 3 Nov 2022 10:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbiKCOYR (ORCPT ); Thu, 3 Nov 2022 10:24:17 -0400 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C49815838; Thu, 3 Nov 2022 07:24:16 -0700 (PDT) Received: by mail-wm1-f49.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so1294771wmq.4; Thu, 03 Nov 2022 07:24:16 -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=X1LT03bLiRuIHRMNZ/VBHuLAuNEKFfSIdBpGFc2+9sA=; b=r1t3vLWxamxM4coqto9QOkOiy1is0Ax+3QyuRBz5axMJZeDIgRWLJOw9n+uoSB1T7K Kq+HOX3D+9un5owkZN5X7gN75ZqwazJ4FeuE0ZBjam3vfx+7XlBp4RgHDKCEbt27A76J 4sNY4+3912HqeZ55Ty+RkP7H6dT2YBjlVFE8DnWPsSYmzEgyrNjyqixdv1jOERcSm6X7 2cvG5j3Rz6WQONgdpNQInMhW9aIpMD1nm3/dUjgLRtUNIt7oeR4+ITLFpxsGgudI51ot wGz/OWr9OUvls81h+PmxEDHw7i5zUP+THIBavlyrwxFV1IRk4NuT6PRgEAgDXfbVpptW jSjg== X-Gm-Message-State: ACrzQf2p72c4spr+BjXbjYdQtVaGYAhpWBRq6xhVcOVNYpzcvMV3oLf1 pz7piTNkhIERo/wEa3rpemY= X-Received: by 2002:a05:600c:4fcf:b0:3c6:cdb9:b68f with SMTP id o15-20020a05600c4fcf00b003c6cdb9b68fmr30684663wmq.73.1667485454723; Thu, 03 Nov 2022 07:24:14 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id fc15-20020a05600c524f00b003cf57329221sm47245wmb.14.2022.11.03.07.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 07:24:14 -0700 (PDT) Date: Thu, 3 Nov 2022 14:24:05 +0000 From: Wei Liu To: "Michael Kelley (LINUX)" Cc: Anirudh Rayabharam , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "wei.liu@kernel.org" , 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=-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 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. I'm holding off sending hyperv-fixes to Linus for now. Thanks, Wei.