From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2837F17FE for ; Fri, 3 Jan 2025 14:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916130; cv=none; b=kKSH4MYVsDbCksd9i9FqhCdYdIB53tV8G8RYZsSgbkxTmbDvlTmaEqycpwiODxuPRwa2DlvVLXhHQDbJ2QDJPRQIIlAnsE9SkZ5frFM3O2TsLtQePI7Dy/Crs1KQSqx+Z+FUEIVkqvb07SE6yY0nf7fs1nLSBq6vhbKElzX17Dw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735916130; c=relaxed/simple; bh=BwW+3SBNnott5QjMaU1EIP/wXQZLr94UDmV+bunimCE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DPqfzMvgK+btUoLrJ9cbSbFTB8pen6KRd5RiFfhdeJ0jilXKGyuFUkLo+BKXDsxuxyszKH44hbys+fQbCw/Ojh3mZx7CUznLeIC7ausp9kydi7wIBegOpsh7Q8B8GcX/RG4a8NKInWcrWA5JpZNk8wtNYcqwHOExrvcK4gycB0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TZCUNaaJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TZCUNaaJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27BB3C4CEDC; Fri, 3 Jan 2025 14:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735916126; bh=BwW+3SBNnott5QjMaU1EIP/wXQZLr94UDmV+bunimCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TZCUNaaJ9yuGYUkRbKVtHGlmTXP0N8KZYZG+tOx4CDiGufS8oYXmDppTmoblbnlO2 ADMSDNGeunGhJnsnnQ2Nx4VgV7NbtQPmNuJKSKrRNP/1++k77VDE8yJq39OnT6UUgU hCxEppw5QTEN9r28s3bSAqdJ27P1bJ0C0Y65iOQYuT64m8A+w4G5DKBZwqqK6TCVly uotzd+Dm4pa73a1SpFe1/XtTF1XaDU4p8wNSoXZsXgTkjA4SIlM1O1aX96kzgpW5XC bCcYGlo8kXnZtuVjWTsnUbmeLCd3alW8IIKNtrINM/oFpgGjf4V2uW1J+yG3JI6Gha gLe4S/DsQdckg== From: Sasha Levin To: stable@vger.kernel.org Cc: Naman Jain , Sasha Levin Subject: Re: [PATCH 5.10.y] x86/hyperv: Fix hv tsc page based sched_clock for hibernation Date: Fri, 3 Jan 2025 09:55:24 -0500 Message-Id: <20250103091251-5a852191ea51fc2d@stable.kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250103054506.1748-1-namjain@linux.microsoft.com> References: Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [ Sasha's backport helper bot ] Hi, Found matching upstream commit: bcc80dec91ee745b3d66f3e48f0ec2efdea97149 Status in newer kernel trees: 6.12.y | Present (different SHA1: bacd0498dea0) 6.6.y | Present (different SHA1: 4c8d45af23c2) 6.1.y | Not found 5.15.y | Not found 5.10.y | Not found Note: The patch differs from the upstream commit: --- 1: bcc80dec91ee ! 1: caa35270fdd9 x86/hyperv: Fix hv tsc page based sched_clock for hibernation @@ Commit message Link: https://lore.kernel.org/r/20240917053917.76787-1-namjain@linux.microsoft.com Signed-off-by: Wei Liu Message-ID: <20240917053917.76787-1-namjain@linux.microsoft.com> + (cherry picked from commit bcc80dec91ee745b3d66f3e48f0ec2efdea97149) + Signed-off-by: Naman Jain ## arch/x86/kernel/cpu/mshyperv.c ## @@ arch/x86/kernel/cpu/mshyperv.c: static void hv_machine_crash_shutdown(struct pt_regs *regs) hyperv_cleanup(); } - #endif /* CONFIG_CRASH_DUMP */ + #endif /* CONFIG_KEXEC_CORE */ + +static u64 hv_ref_counter_at_suspend; +static void (*old_save_sched_clock_state)(void); @@ arch/x86/kernel/cpu/mshyperv.c: static void __init ms_hyperv_init_platform(void) /* Register Hyper-V specific clocksource */ hv_init_clocksource(); + x86_setup_ops_for_tsc_pg_clock(); - hv_vtl_init_platform(); #endif /* + * TSC should be marked as unstable only after Hyper-V ## drivers/clocksource/hyperv_timer.c ## @@ @@ drivers/clocksource/hyperv_timer.c /* * If false, we're using the old mechanism for stimer0 interrupts @@ drivers/clocksource/hyperv_timer.c: static void resume_hv_clock_tsc(struct clocksource *arg) - hv_set_msr(HV_MSR_REFERENCE_TSC, tsc_msr.as_uint64); + hv_set_reference_tsc(tsc_msr); } +/* @@ drivers/clocksource/hyperv_timer.c: static void resume_hv_clock_tsc(struct clock + hv_sched_clock_offset -= offset; +} + - #ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK static int hv_cs_enable(struct clocksource *cs) { + hv_enable_vdso_clocksource(); ## include/clocksource/hyperv_timer.h ## -@@ include/clocksource/hyperv_timer.h: extern void hv_remap_tsc_clocksource(void); - extern unsigned long hv_get_tsc_pfn(void); +@@ include/clocksource/hyperv_timer.h: extern void hv_init_clocksource(void); + extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void); +extern void hv_adj_sched_clock_offset(u64 offset); + - static __always_inline bool - hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, - u64 *cur_tsc, u64 *time) + static inline notrace u64 + hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg, u64 *cur_tsc) + { --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-5.10.y | Success | Success |