Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2747789rwi; Tue, 1 Nov 2022 11:13:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM75GFu7loW5p495OkGlWauI3icW9Iz1qYd3G8CIukNT7z0WHv/FzNjtCvQ3Z7x0Hd8SXVNw X-Received: by 2002:a17:902:9f8f:b0:187:161d:4f32 with SMTP id g15-20020a1709029f8f00b00187161d4f32mr15430860plq.79.1667326408193; Tue, 01 Nov 2022 11:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667326408; cv=none; d=google.com; s=arc-20160816; b=PRaY8dFNiugGR6lulV5ACk5Sw2lYhONqu5yStFnEDM93acCmjHv3O+tNkReJgEWH5y G+kOYH0TD0iTEFt99qC1hfBq/7GuZri7K8r9X6YhqE0kceyZfP7Z9hTgTXrGNDiUGst2 3jtmqgYa/4spp5yiMD3AziLezuuTMmYqffPVQ40y6d4gGBb5mmazZSDKf5HooMahEvVI q2RHZ+HyDewTTfFU2eJUG6t09PT9PwYuXnFExZNSTBGI3YzVTialWpBRRZNF1iByjo/3 hUMAcOpKQZmM4upIcxTcooQUEIwinX9/lWm8d/yC4SSf8gVjQSuvaRMnyDOvbRQ/4H7/ H+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:from:subject :dkim-signature:dkim-filter; bh=gzbi2cZL78wkI/YYwutmnQjWwUdGs2YRrCc1CbsM23M=; b=tu2EopJxYFZDfgMelak8CVs4cZtvm/5z8z6ETeq3eaMM2V5VTzOTFOawzBNA/E5grH iwoMzqc24bkGlauBZDqS8rs13zn9/uVNBXgoIDRDBdUUn+cfCXcBrIR1jgOIO1VRi5dz G1N6RTvrL8yjrkQ3E1PzZssRKM3ukBExgJ0bi2I3nhCrfJMkr0aO0JEee1KlkwlP7qXG eN5fKh+q12y63XWtv4ZRK8/kezjB1gY8Ch/v/z/ueZ5rNYLN0ZqEr6pF7VHfr65ZnxJg /hAMyBZfvf7RxpybrXkePU1HhITZkO9iXf+vqoc9vC2MB/SL16ygX0LT3/OyTpS9LdTu CmRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Dp8fRevR; 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 nm22-20020a17090b19d600b0020a1c6bb23csi11751132pjb.74.2022.11.01.11.13.15; Tue, 01 Nov 2022 11:13:28 -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=Dp8fRevR; 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 S230253AbiKARbX (ORCPT + 96 others); Tue, 1 Nov 2022 13:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbiKARbQ (ORCPT ); Tue, 1 Nov 2022 13:31:16 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A0821C134; Tue, 1 Nov 2022 10:31:15 -0700 (PDT) Received: from skinsburskii-cloud-desktop.internal.cloudapp.net (unknown [20.120.152.163]) by linux.microsoft.com (Postfix) with ESMTPSA id 4008D20B9F80; Tue, 1 Nov 2022 10:31:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4008D20B9F80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667323875; bh=gzbi2cZL78wkI/YYwutmnQjWwUdGs2YRrCc1CbsM23M=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=Dp8fRevRUiByRldOLyNZVh3jh0kTfvjocg7HEKUIBtW5U6i32+7W9R6yp9Hp8K4Aa IEz5Ysl9V4PNsmYUWX9CrT+2gUJCmhqJ8k2/fLRLUT6jAFztmV0FuRAY3D5JiIegpV wS5aGv8KQovg4fkkfW6BNdMHQxpF7Sx7g5rH9LYM= Subject: [PATCH 3/4] drivers/clocksource/hyper-v: Use TSC PFN getter to map vvar page From: Stanislav Kinsburskii Cc: Stanislav Kinsburskiy , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Daniel Lezcano , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Date: Tue, 01 Nov 2022 17:31:15 +0000 Message-ID: <166732387510.9827.8987757583900408743.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> In-Reply-To: <166732356767.9827.4925884794177179249.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> References: <166732356767.9827.4925884794177179249.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-18.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,MISSING_HEADERS, 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Kinsburskiy Instead of converting the virtual address to physical directly. This is a precursor patch for the upcoming support for TSC page mapping into hyper-v root partition, which address will be defined by the hypervisor and mapped into the kernel. Signed-off-by: Stanislav Kinsburskiy CC: Andy Lutomirski CC: Thomas Gleixner CC: Ingo Molnar CC: Borislav Petkov CC: Dave Hansen CC: x86@kernel.org CC: "H. Peter Anvin" CC: "K. Y. Srinivasan" CC: Haiyang Zhang CC: Wei Liu CC: Dexuan Cui CC: Daniel Lezcano CC: linux-kernel@vger.kernel.org CC: linux-hyperv@vger.kernel.org --- arch/x86/entry/vdso/vma.c | 7 +++---- drivers/clocksource/hyperv_timer.c | 3 ++- include/clocksource/hyperv_timer.h | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 311eae30e089..6976416b2c9f 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -210,11 +210,10 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, pgprot_decrypted(vma->vm_page_prot)); } } else if (sym_offset == image->sym_hvclock_page) { - struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page(); + pfn = hv_get_tsc_pfn(); - if (tsc_pg && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK)) - return vmf_insert_pfn(vma, vmf->address, - virt_to_phys(tsc_pg) >> PAGE_SHIFT); + if (pfn && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK)) + return vmf_insert_pfn(vma, vmf->address, pfn); } else if (sym_offset == image->sym_timens_page) { struct page *timens_page = find_timens_vvar_page(vma); diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index d447bc99a399..635c14c1e3bf 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -369,10 +369,11 @@ static union { static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page; static unsigned long tsc_pfn; -static unsigned long hv_get_tsc_pfn(void) +unsigned long hv_get_tsc_pfn(void) { return tsc_pfn; } +EXPORT_SYMBOL_GPL(hv_get_tsc_pfn); struct ms_hyperv_tsc_page *hv_get_tsc_page(void) { diff --git a/include/clocksource/hyperv_timer.h b/include/clocksource/hyperv_timer.h index b3f5d73ae1d6..3078d23faaea 100644 --- a/include/clocksource/hyperv_timer.h +++ b/include/clocksource/hyperv_timer.h @@ -32,6 +32,7 @@ extern void hv_stimer0_isr(void); extern void hv_init_clocksource(void); +extern unsigned long hv_get_tsc_pfn(void); extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void); static inline notrace u64 @@ -90,6 +91,11 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg) } #else /* CONFIG_HYPERV_TIMER */ +static inline unsigned long hv_get_tsc_pfn(void) +{ + return 0; +} + static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void) { return NULL;