Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1965393rwi; Thu, 3 Nov 2022 11:01:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eeB24Gput9eZEroIiQRW3CeY0NcO5hEnFm+jOdVS+yV1lWgwEJjAr8+7Ws4Jy83DtS7+N X-Received: by 2002:a17:90b:38c3:b0:213:5ccc:9736 with SMTP id nn3-20020a17090b38c300b002135ccc9736mr32121541pjb.196.1667498515632; Thu, 03 Nov 2022 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667498515; cv=none; d=google.com; s=arc-20160816; b=tLsv/xT0nXIS6TZYuHKZ4V14O7ydGycAHfFS9F8zfcjpv6vxKppy5PxYl54Cu9oHwN +xe2ILbFLMb/CvDBKoOwVvUvWeP4WBFIYrgYKnH354opXCrN5EmxtXD/ktLP6LJ6/tDx 2x0RIBr5S2A3y/moWW2tusbDD3QAer5gPrglfjjim4rkJ8LvA/RPO7+jS6f9pBe8Dlbn wlKEIf6jZO3GII/hWcZUR4mLBfPLEbgZwmzHzoSofLWktv291XzfeM3SgPF9feF3u24n OSdNWDME5xtKUQP2nIDwYlLN05+b+MYCB1CDQAxO9pOfOzqD46l/CP0v6oE/owACGr6B tG/A== 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=Y5FIS1UinMZxnexhjB33RzhGI8ZZkhrWDexZaDMwgyw=; b=o78iHAAtUkukEO/y+mznZoxaRc34s+yWsJ0ABsnk2Ku28ZLWwmV5ZJmfqMuhf3wk7D gcs2PmnVJLR6C+hfmf9sh4IqQOpOxEbIDf7RVDrxN7SJIKhDzVJKGn9cTDZ999AXRGRA gMtIijw+882AefbJGiuzEly9cJvhLRHQjXRACSlsAeBXXswYeHMSLknpliV5QDZpYnpx QIo5RexEmY5YwNJyuIx8przSqVHBfGvzR3hLzD9z3Gp6E+Y6Ld6fh/1kxfZkYGahjSOb 4A0Xh91irZf7znmRhSUJlRkUFql2X+u4RyHPQFpIrrzXc2pXKvx4oof85qJRcgfCbaoh Xrdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=LFRZUZTP; 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 f8-20020a056a0022c800b0056cb8f6f027si1800748pfj.357.2022.11.03.11.01.30; Thu, 03 Nov 2022 11:01:55 -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=LFRZUZTP; 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 S231899AbiKCR7Q (ORCPT + 98 others); Thu, 3 Nov 2022 13:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiKCR7I (ORCPT ); Thu, 3 Nov 2022 13:59:08 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB82B2197; Thu, 3 Nov 2022 10:58:59 -0700 (PDT) Received: from skinsburskii-cloud-desktop.internal.cloudapp.net (unknown [20.120.152.163]) by linux.microsoft.com (Postfix) with ESMTPSA id 8B0A5205DA3E; Thu, 3 Nov 2022 10:58:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8B0A5205DA3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667498339; bh=Y5FIS1UinMZxnexhjB33RzhGI8ZZkhrWDexZaDMwgyw=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=LFRZUZTPZzXnmqxogF0vtBFfURfydGni/8XJCj3i6Dly0qcTr+ZmnBNAP/EoCqv6h +ijRhkhZ74WTb0VIpahmR7TLT1lJ+4H/xug34Tg+QS6Qo/lsamBOsZvJHS+8BkGYZo Pch+65CysJw0L85LGxwqrcXTMiY1bmZN/OmYsTCQ= Subject: [PATCH v3 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, mikelley@microsoft.com Date: Thu, 03 Nov 2022 17:58:59 +0000 Message-ID: <166749833939.218190.14095015146003109462.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> In-Reply-To: <166749827889.218190.12775118554387271641.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> References: <166749827889.218190.12775118554387271641.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 b7af19d06b51..9445a1558fe9 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -370,10 +370,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;