Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp593302rwi; Wed, 2 Nov 2022 15:55:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n4jsSab1PdBMHK/p6sr/hwnfSuM4Szljcm/3qvn4Y2cNOvrNP3KfTydFQhuj6EjJ+8NST X-Received: by 2002:a05:6a00:1ad2:b0:56d:ec92:9825 with SMTP id f18-20020a056a001ad200b0056dec929825mr7864830pfv.25.1667429747818; Wed, 02 Nov 2022 15:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667429747; cv=none; d=google.com; s=arc-20160816; b=A6zFzVk3dO7weuMcRZRnRv6NOmO/a5d+oEbpTWbLaGmrtYEJVCZ9gjlg1NoyZXi9i4 KfA1tVsNKhSvcQszcXDpHlSwFHrFUyBCPooHbHfdtw6hmV19RkTmab3UtHmW6k4hlLLP 1C5ivH6cRUdfxNu8/sHWVfQNJvOr6sf7w5bAyXpeDCjvSkpfTbFAexBch8EStz42wLef qsVYt6q/K61/zh+Fesk1S84GNE+Sxcktgv0y99iDopi8ODCD1jXLLW3o+eudOEt+2gA2 9cEddK58FveS+DTZOeX9JdlKsNl1EFfTYJ+05GKbWwmCByjTbWYEhEFE68xRqET1YjYn 5CfQ== 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=pAbglJaMPSpg4VSsz2BLMewqFuaTia6tHnF0dX8Qngc=; b=YJTtBm10TKSQ7bJQ7DpSKTl8pNrXI+p6ERuXHpz3zF6UZm+6QEbmdcBJT+oITm8c09 gbuzZ1dWYC3elOT/e1lO4eNI8u9uzzKzTNGVo015mjaZOtbeNlNCtNxJq8MbKTrjVwKo hkKhC2CcO06iJ8ZCFeBrFW1heoA2vCcTpkp0GDG1nvIIeCwjsJCp30UcivuykqBnOum+ 0YQCHtQbkIYcgP9xVXU+36fXAIj43EW1XUGFFAGP9nuzysOWIaPnax2WqMpFaC8pwdbE fg27D6VmLx+QLNOZnwr0hjpbbUrxzHkzMVSVBq4rqL4DfzN3D9mgcO3KswR3CyGyAbzs P4Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=a89uZ9SZ; 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 21-20020a630415000000b00456f7329d13si17948139pge.279.2022.11.02.15.55.35; Wed, 02 Nov 2022 15:55:47 -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=a89uZ9SZ; 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 S231444AbiKBWIH (ORCPT + 97 others); Wed, 2 Nov 2022 18:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiKBWHv (ORCPT ); Wed, 2 Nov 2022 18:07:51 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 33D04101DE; Wed, 2 Nov 2022 15:07:35 -0700 (PDT) Received: from skinsburskii-cloud-desktop.internal.cloudapp.net (unknown [20.120.152.163]) by linux.microsoft.com (Postfix) with ESMTPSA id D1B0C20C3338; Wed, 2 Nov 2022 15:07:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D1B0C20C3338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667426854; bh=pAbglJaMPSpg4VSsz2BLMewqFuaTia6tHnF0dX8Qngc=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=a89uZ9SZdrYi8fjGMkYo24jWukdNB2plQwLTlnp0ispi6zn+uvsKSPK46QjsRj8g/ RNtSnphhHVLYc1ktjER/vLSAOi4b3gdmTn5zaZoVSV8g/i86Cxp/3oqM9aO/21loJW bgXchQVwv6CrG7Hq5hlMEx/Y1PdGG7JzcOjcyrIU= Subject: [PATCH v2 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: Wed, 02 Nov 2022 22:07:34 +0000 Message-ID: <166742685472.205987.8150649341873398568.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> In-Reply-To: <166742670556.205987.18227942188746093700.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> References: <166742670556.205987.18227942188746093700.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 Microsoft Hypervisor root partition, where TSC PFN will be defined by the hypervisor and thus can't be obtained by linear translation of the physical address. 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;