]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 6.6
authorSasha Levin <sashal@kernel.org>
Mon, 4 Dec 2023 10:40:08 +0000 (05:40 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 4 Dec 2023 10:40:08 +0000 (05:40 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-6.6/drm-amd-display-fix-mpcc-1dlut-programming.patch [new file with mode: 0644]
queue-6.6/drm-amd-display-increase-num-voltage-states-to-40.patch [new file with mode: 0644]
queue-6.6/drm-amd-display-reduce-default-backlight-min-from-5-.patch [new file with mode: 0644]
queue-6.6/drm-amd-display-refactor-ilr-to-make-it-work.patch [new file with mode: 0644]
queue-6.6/drm-amd-display-simplify-brightness-initialization.patch [new file with mode: 0644]
queue-6.6/series
queue-6.6/vfio-drop-vfio_file_iommu_group-stub-to-fudge-around.patch [new file with mode: 0644]
queue-6.6/vfio-pds-fix-mutex-lock-magic-lock-warning.patch [new file with mode: 0644]
queue-6.6/vfio-pds-fix-possible-sleep-while-in-atomic-context.patch [new file with mode: 0644]
queue-6.6/x86-xen-fix-percpu-vcpu_info-allocation.patch [new file with mode: 0644]

diff --git a/queue-6.6/drm-amd-display-fix-mpcc-1dlut-programming.patch b/queue-6.6/drm-amd-display-fix-mpcc-1dlut-programming.patch
new file mode 100644 (file)
index 0000000..2ba3e2b
--- /dev/null
@@ -0,0 +1,53 @@
+From 262eb50e05e8da721bba8d4ceeb7a1219dfa8cb6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Nov 2023 15:07:56 -0500
+Subject: drm/amd/display: Fix MPCC 1DLUT programming
+
+From: Ilya Bakoulin <ilya.bakoulin@amd.com>
+
+[ Upstream commit 6f395cebdd8927fbffdc3a55a14fcacf93634359 ]
+
+[Why]
+Wrong function is used to translate LUT values to HW format, leading to
+visible artifacting in some cases.
+
+[How]
+Use the correct cm3_helper function.
+
+Cc: stable@vger.kernel.org # 6.1+
+Reviewed-by: Krunoslav Kovac <krunoslav.kovac@amd.com>
+Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
+Signed-off-by: Ilya Bakoulin <ilya.bakoulin@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
+index c9140b50c3454..650e1598bddcb 100644
+--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
++++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
+@@ -486,8 +486,7 @@ bool dcn32_set_mcm_luts(
+               if (plane_state->blend_tf->type == TF_TYPE_HWPWL)
+                       lut_params = &plane_state->blend_tf->pwl;
+               else if (plane_state->blend_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
+-                      cm_helper_translate_curve_to_hw_format(plane_state->ctx,
+-                                      plane_state->blend_tf,
++                      cm3_helper_translate_curve_to_hw_format(plane_state->blend_tf,
+                                       &dpp_base->regamma_params, false);
+                       lut_params = &dpp_base->regamma_params;
+               }
+@@ -501,8 +500,7 @@ bool dcn32_set_mcm_luts(
+               else if (plane_state->in_shaper_func->type == TF_TYPE_DISTRIBUTED_POINTS) {
+                       // TODO: dpp_base replace
+                       ASSERT(false);
+-                      cm_helper_translate_curve_to_hw_format(plane_state->ctx,
+-                                      plane_state->in_shaper_func,
++                      cm3_helper_translate_curve_to_hw_format(plane_state->in_shaper_func,
+                                       &dpp_base->shaper_params, true);
+                       lut_params = &dpp_base->shaper_params;
+               }
+-- 
+2.42.0
+
diff --git a/queue-6.6/drm-amd-display-increase-num-voltage-states-to-40.patch b/queue-6.6/drm-amd-display-increase-num-voltage-states-to-40.patch
new file mode 100644 (file)
index 0000000..e2861e4
--- /dev/null
@@ -0,0 +1,42 @@
+From 2ad2b53e6f5b836815feafbfd156ab73320c8360 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Nov 2023 17:16:28 -0500
+Subject: drm/amd/display: Increase num voltage states to 40
+
+From: Alvin Lee <alvin.lee2@amd.com>
+
+[ Upstream commit 67e38874b85b8df7b23d29f78ac3d7ecccd9519d ]
+
+[Description]
+If during driver init stage there are greater than 20
+intermediary voltage states while constructing the SOC
+BB we could hit issues because we will index outside of the
+clock_limits array and start overwriting data. Increase the
+total number of states to 40 to avoid this issue.
+
+Cc: stable@vger.kernel.org # 6.1+
+Reviewed-by: Samson Tam <samson.tam@amd.com>
+Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
+Signed-off-by: Alvin Lee <alvin.lee2@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/display/dc/dml/dc_features.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/dml/dc_features.h b/drivers/gpu/drm/amd/display/dc/dml/dc_features.h
+index 2cbdd75429ffd..6e669a2c5b2d4 100644
+--- a/drivers/gpu/drm/amd/display/dc/dml/dc_features.h
++++ b/drivers/gpu/drm/amd/display/dc/dml/dc_features.h
+@@ -36,7 +36,7 @@
+  * Define the maximum amount of states supported by the ASIC. Every ASIC has a
+  * specific number of states; this macro defines the maximum number of states.
+  */
+-#define DC__VOLTAGE_STATES 20
++#define DC__VOLTAGE_STATES 40
+ #define DC__NUM_DPP__4 1
+ #define DC__NUM_DPP__0_PRESENT 1
+ #define DC__NUM_DPP__1_PRESENT 1
+-- 
+2.42.0
+
diff --git a/queue-6.6/drm-amd-display-reduce-default-backlight-min-from-5-.patch b/queue-6.6/drm-amd-display-reduce-default-backlight-min-from-5-.patch
new file mode 100644 (file)
index 0000000..4f6f884
--- /dev/null
@@ -0,0 +1,43 @@
+From f0af59d97798db902949b42c095aab2c18d6400a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Oct 2023 15:58:57 -0400
+Subject: drm/amd/display: Reduce default backlight min from 5 nits to 1 nits
+
+From: Swapnil Patel <swapnil.patel@amd.com>
+
+[ Upstream commit 5edb7cdff85af8f8c5fda5b88310535ab823f663 ]
+
+[Why & How]
+Currently set_default_brightness_aux function uses 5 nits as lower limit
+to check for valid default_backlight setting. However some newer panels
+can support even lower default settings
+
+Reviewed-by: Agustin Gutierrez <agustin.gutierrez@amd.com>
+Acked-by: Roman Li <roman.li@amd.com>
+Signed-off-by: Swapnil Patel <swapnil.patel@amd.com>
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Stable-dep-of: d9e865826c20 ("drm/amd/display: Simplify brightness initialization")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../amd/display/dc/link/protocols/link_edp_panel_control.c    | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+index e1708c296b7df..a602202610e09 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+@@ -281,8 +281,8 @@ bool set_default_brightness_aux(struct dc_link *link)
+       if (link && link->dpcd_sink_ext_caps.bits.oled == 1) {
+               if (!read_default_bl_aux(link, &default_backlight))
+                       default_backlight = 150000;
+-              // if < 5 nits or > 5000, it might be wrong readback
+-              if (default_backlight < 5000 || default_backlight > 5000000)
++              // if < 1 nits or > 5000, it might be wrong readback
++              if (default_backlight < 1000 || default_backlight > 5000000)
+                       default_backlight = 150000; //
+               return edp_set_backlight_level_nits(link, true,
+-- 
+2.42.0
+
diff --git a/queue-6.6/drm-amd-display-refactor-ilr-to-make-it-work.patch b/queue-6.6/drm-amd-display-refactor-ilr-to-make-it-work.patch
new file mode 100644 (file)
index 0000000..e148050
--- /dev/null
@@ -0,0 +1,152 @@
+From a8f329acb797e6e39b3c3435b47a2111ae5d149d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 8 Sep 2023 14:45:00 +0800
+Subject: drm/amd/display: refactor ILR to make it work
+
+From: Sherry Wang <yao.wang1@amd.com>
+
+[ Upstream commit 6ec876472ff7edeaf2a07bf6afbff74d7f1dfa35 ]
+
+[Why]
+Current ILR toggle is on/off as a part of panel
+config for new function, which breaks original
+ILR logic
+
+[How]
+Refactor ILR and take panel config into account
+
+Reviewed-by: Anthony Koo <anthony.koo@amd.com>
+Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
+Signed-off-by: Sherry Wang <yao.wang1@amd.com>
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Stable-dep-of: d9e865826c20 ("drm/amd/display: Simplify brightness initialization")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../drm/amd/display/dc/link/link_detection.c  |  6 ++++++
+ .../dc/link/protocols/link_dp_capability.c    | 14 ++++---------
+ .../link/protocols/link_edp_panel_control.c   | 21 +++++++++++++++++--
+ .../link/protocols/link_edp_panel_control.h   |  2 ++
+ 4 files changed, 31 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+index e682d27e098f8..b3d3e46c466b3 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
++++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+@@ -1166,6 +1166,12 @@ static bool detect_link_and_local_sink(struct dc_link *link,
+                       dm_helpers_init_panel_settings(dc_ctx, &link->panel_config, sink);
+                       // Override dc_panel_config if system has specific settings
+                       dm_helpers_override_panel_settings(dc_ctx, &link->panel_config);
++
++                      //sink only can use supported link rate table, we are foreced to enable it
++                      if (link->reported_link_cap.link_rate == LINK_RATE_UNKNOWN)
++                              link->panel_config.ilr.optimize_edp_link_rate = true;
++                      if (edp_is_ilr_optimization_enabled(link))
++                              link->reported_link_cap.link_rate = get_max_link_rate_from_ilr_table(link);
+               }
+       } else {
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
+index 237e0ff955f3c..db87aa7b5c90f 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
+@@ -707,8 +707,7 @@ bool edp_decide_link_settings(struct dc_link *link,
+        * edp_supported_link_rates_count is only valid for eDP v1.4 or higher.
+        * Per VESA eDP spec, "The DPCD revision for eDP v1.4 is 13h"
+        */
+-      if (link->dpcd_caps.dpcd_rev.raw < DPCD_REV_13 ||
+-                      link->dpcd_caps.edp_supported_link_rates_count == 0) {
++      if (!edp_is_ilr_optimization_enabled(link)) {
+               *link_setting = link->verified_link_cap;
+               return true;
+       }
+@@ -772,8 +771,7 @@ bool decide_edp_link_settings_with_dsc(struct dc_link *link,
+        * edp_supported_link_rates_count is only valid for eDP v1.4 or higher.
+        * Per VESA eDP spec, "The DPCD revision for eDP v1.4 is 13h"
+        */
+-      if ((link->dpcd_caps.dpcd_rev.raw < DPCD_REV_13 ||
+-                      link->dpcd_caps.edp_supported_link_rates_count == 0)) {
++      if (!edp_is_ilr_optimization_enabled(link)) {
+               /* for DSC enabled case, we search for minimum lane count */
+               memset(&initial_link_setting, 0, sizeof(initial_link_setting));
+               initial_link_setting.lane_count = LANE_COUNT_ONE;
+@@ -1938,9 +1936,7 @@ void detect_edp_sink_caps(struct dc_link *link)
+        * edp_supported_link_rates_count is only valid for eDP v1.4 or higher.
+        * Per VESA eDP spec, "The DPCD revision for eDP v1.4 is 13h"
+        */
+-      if (link->dpcd_caps.dpcd_rev.raw >= DPCD_REV_13 &&
+-                      (link->panel_config.ilr.optimize_edp_link_rate ||
+-                      link->reported_link_cap.link_rate == LINK_RATE_UNKNOWN)) {
++      if (link->dpcd_caps.dpcd_rev.raw >= DPCD_REV_13) {
+               // Read DPCD 00010h - 0001Fh 16 bytes at one shot
+               core_link_read_dpcd(link, DP_SUPPORTED_LINK_RATES,
+                                                       supported_link_rates, sizeof(supported_link_rates));
+@@ -1958,12 +1954,10 @@ void detect_edp_sink_caps(struct dc_link *link)
+                               link_rate = linkRateInKHzToLinkRateMultiplier(link_rate_in_khz);
+                               link->dpcd_caps.edp_supported_link_rates[link->dpcd_caps.edp_supported_link_rates_count] = link_rate;
+                               link->dpcd_caps.edp_supported_link_rates_count++;
+-
+-                              if (link->reported_link_cap.link_rate < link_rate)
+-                                      link->reported_link_cap.link_rate = link_rate;
+                       }
+               }
+       }
++
+       core_link_read_dpcd(link, DP_EDP_BACKLIGHT_ADJUSTMENT_CAP,
+                                               &backlight_adj_cap, sizeof(backlight_adj_cap));
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+index 24b47fa82f93c..e1708c296b7df 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+@@ -300,6 +300,24 @@ bool set_cached_brightness_aux(struct dc_link *link)
+               return set_default_brightness_aux(link);
+       return false;
+ }
++bool edp_is_ilr_optimization_enabled(struct dc_link *link)
++{
++      if (link->dpcd_caps.edp_supported_link_rates_count == 0 || !link->panel_config.ilr.optimize_edp_link_rate)
++              return false;
++      return true;
++}
++
++enum dc_link_rate get_max_link_rate_from_ilr_table(struct dc_link *link)
++{
++      enum dc_link_rate link_rate = link->reported_link_cap.link_rate;
++
++      for (int i = 0; i < link->dpcd_caps.edp_supported_link_rates_count; i++) {
++              if (link_rate < link->dpcd_caps.edp_supported_link_rates[i])
++                      link_rate = link->dpcd_caps.edp_supported_link_rates[i];
++      }
++
++      return link_rate;
++}
+ bool edp_is_ilr_optimization_required(struct dc_link *link,
+               struct dc_crtc_timing *crtc_timing)
+@@ -312,8 +330,7 @@ bool edp_is_ilr_optimization_required(struct dc_link *link,
+       ASSERT(link || crtc_timing); // invalid input
+-      if (link->dpcd_caps.edp_supported_link_rates_count == 0 ||
+-                      !link->panel_config.ilr.optimize_edp_link_rate)
++      if (!edp_is_ilr_optimization_enabled(link))
+               return false;
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
+index 20f91de852e30..ebf7deb63d136 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
+@@ -64,6 +64,8 @@ bool edp_get_replay_state(const struct dc_link *link, uint64_t *state);
+ bool edp_wait_for_t12(struct dc_link *link);
+ bool edp_is_ilr_optimization_required(struct dc_link *link,
+        struct dc_crtc_timing *crtc_timing);
++bool edp_is_ilr_optimization_enabled(struct dc_link *link);
++enum dc_link_rate get_max_link_rate_from_ilr_table(struct dc_link *link);
+ bool edp_backlight_enable_aux(struct dc_link *link, bool enable);
+ void edp_add_delay_for_T9(struct dc_link *link);
+ bool edp_receiver_ready_T9(struct dc_link *link);
+-- 
+2.42.0
+
diff --git a/queue-6.6/drm-amd-display-simplify-brightness-initialization.patch b/queue-6.6/drm-amd-display-simplify-brightness-initialization.patch
new file mode 100644 (file)
index 0000000..c515311
--- /dev/null
@@ -0,0 +1,145 @@
+From 60844d42054b1eb039a07354034bd746cfe38176 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 12:08:42 +0800
+Subject: drm/amd/display: Simplify brightness initialization
+
+From: Camille Cho <camille.cho@amd.com>
+
+[ Upstream commit d9e865826c202b262f9ee3f17a03cc4ac5d44ced ]
+
+[Why]
+Remove the brightness cache in DC. It uses a single value to represent
+the brightness for both SDR and HDR mode. This leads to flash in HDR
+on/off. It also unconditionally programs brightness as in HDR mode. This
+may introduce garbage on SDR mode in miniLED panel.
+
+[How]
+Simplify the initialization flow by removing the DC cache and taking
+what panel has as default. Expand the mechanism for PWM to DPCD Aux to
+restore cached brightness value generally.
+
+Cc: stable@vger.kernel.org # 6.1+
+Reviewed-by: Krunoslav Kovac <krunoslav.kovac@amd.com>
+Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
+Signed-off-by: Camille Cho <camille.cho@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/display/dc/dc.h              |  1 -
+ drivers/gpu/drm/amd/display/dc/dc_types.h        |  4 ----
+ .../gpu/drm/amd/display/dc/link/link_detection.c |  2 +-
+ drivers/gpu/drm/amd/display/dc/link/link_dpms.c  |  3 +--
+ .../dc/link/protocols/link_edp_panel_control.c   | 16 +++-------------
+ .../dc/link/protocols/link_edp_panel_control.h   |  1 -
+ 6 files changed, 5 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
+index dd7bf31ef6b04..3f33740e2f659 100644
+--- a/drivers/gpu/drm/amd/display/dc/dc.h
++++ b/drivers/gpu/drm/amd/display/dc/dc.h
+@@ -1538,7 +1538,6 @@ struct dc_link {
+       enum edp_revision edp_revision;
+       union dpcd_sink_ext_caps dpcd_sink_ext_caps;
+-      struct backlight_settings backlight_settings;
+       struct psr_settings psr_settings;
+       struct replay_settings replay_settings;
+diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h
+index ba900b0a62a82..accffba5a6834 100644
+--- a/drivers/gpu/drm/amd/display/dc/dc_types.h
++++ b/drivers/gpu/drm/amd/display/dc/dc_types.h
+@@ -1003,10 +1003,6 @@ struct link_mst_stream_allocation_table {
+       struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
+ };
+-struct backlight_settings {
+-      uint32_t backlight_millinits;
+-};
+-
+ /* PSR feature flags */
+ struct psr_settings {
+       bool psr_feature_enabled;               // PSR is supported by sink
+diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+index b3d3e46c466b3..c7a9e286a5d4d 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
++++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+@@ -876,7 +876,7 @@ static bool detect_link_and_local_sink(struct dc_link *link,
+                       (link->dpcd_sink_ext_caps.bits.oled == 1)) {
+                       dpcd_set_source_specific_data(link);
+                       msleep(post_oui_delay);
+-                      set_cached_brightness_aux(link);
++                      set_default_brightness_aux(link);
+               }
+               return true;
+diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c b/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
+index a17a06eb7762b..35d087cf1980f 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
++++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
+@@ -2140,8 +2140,7 @@ static enum dc_status enable_link_dp(struct dc_state *state,
+       if (link->dpcd_sink_ext_caps.bits.oled == 1 ||
+               link->dpcd_sink_ext_caps.bits.sdr_aux_backlight_control == 1 ||
+               link->dpcd_sink_ext_caps.bits.hdr_aux_backlight_control == 1) {
+-              set_cached_brightness_aux(link);
+-
++              set_default_brightness_aux(link);
+               if (link->dpcd_sink_ext_caps.bits.oled == 1)
+                       msleep(bl_oled_enable_delay);
+               edp_backlight_enable_aux(link, true);
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+index a602202610e09..fe74d4252a510 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+@@ -168,7 +168,6 @@ bool edp_set_backlight_level_nits(struct dc_link *link,
+       *(uint32_t *)&dpcd_backlight_set.backlight_level_millinits = backlight_millinits;
+       *(uint16_t *)&dpcd_backlight_set.backlight_transition_time_ms = (uint16_t)transition_time_in_ms;
+-      link->backlight_settings.backlight_millinits = backlight_millinits;
+       if (!link->dpcd_caps.panel_luminance_control) {
+               if (core_link_write_dpcd(link, DP_SOURCE_BACKLIGHT_LEVEL,
+@@ -281,9 +280,9 @@ bool set_default_brightness_aux(struct dc_link *link)
+       if (link && link->dpcd_sink_ext_caps.bits.oled == 1) {
+               if (!read_default_bl_aux(link, &default_backlight))
+                       default_backlight = 150000;
+-              // if < 1 nits or > 5000, it might be wrong readback
+-              if (default_backlight < 1000 || default_backlight > 5000000)
+-                      default_backlight = 150000; //
++              // if > 5000, it might be wrong readback
++              if (default_backlight > 5000000)
++                      default_backlight = 150000;
+               return edp_set_backlight_level_nits(link, true,
+                               default_backlight, 0);
+@@ -291,15 +290,6 @@ bool set_default_brightness_aux(struct dc_link *link)
+       return false;
+ }
+-bool set_cached_brightness_aux(struct dc_link *link)
+-{
+-      if (link->backlight_settings.backlight_millinits)
+-              return edp_set_backlight_level_nits(link, true,
+-                                                  link->backlight_settings.backlight_millinits, 0);
+-      else
+-              return set_default_brightness_aux(link);
+-      return false;
+-}
+ bool edp_is_ilr_optimization_enabled(struct dc_link *link)
+ {
+       if (link->dpcd_caps.edp_supported_link_rates_count == 0 || !link->panel_config.ilr.optimize_edp_link_rate)
+diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
+index ebf7deb63d136..a034288ad75d4 100644
+--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
++++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h
+@@ -30,7 +30,6 @@
+ enum dp_panel_mode dp_get_panel_mode(struct dc_link *link);
+ void dp_set_panel_mode(struct dc_link *link, enum dp_panel_mode panel_mode);
+ bool set_default_brightness_aux(struct dc_link *link);
+-bool set_cached_brightness_aux(struct dc_link *link);
+ void edp_panel_backlight_power_on(struct dc_link *link, bool wait_for_hpd);
+ int edp_get_backlight_level(const struct dc_link *link);
+ bool edp_get_backlight_level_nits(struct dc_link *link,
+-- 
+2.42.0
+
index b430f2c5d3643245709830b6999132a80eccf53d..1c7e565ceabcc7b34c93ade8ae5e7b1264fe87d9 100644 (file)
@@ -124,3 +124,12 @@ cpufreq-amd-pstate-fix-scaling_min_freq-and-scaling_.patch
 cpufreq-amd-pstate-only-print-supported-epp-values-f.patch
 drm-amd-pm-fix-a-memleak-in-aldebaran_tables_init.patch
 iommu-fix-printk-arg-in-of_iommu_get_resv_regions.patch
+drm-amd-display-refactor-ilr-to-make-it-work.patch
+drm-amd-display-reduce-default-backlight-min-from-5-.patch
+drm-amd-display-simplify-brightness-initialization.patch
+drm-amd-display-increase-num-voltage-states-to-40.patch
+drm-amd-display-fix-mpcc-1dlut-programming.patch
+vfio-pds-fix-mutex-lock-magic-lock-warning.patch
+vfio-pds-fix-possible-sleep-while-in-atomic-context.patch
+x86-xen-fix-percpu-vcpu_info-allocation.patch
+vfio-drop-vfio_file_iommu_group-stub-to-fudge-around.patch
diff --git a/queue-6.6/vfio-drop-vfio_file_iommu_group-stub-to-fudge-around.patch b/queue-6.6/vfio-drop-vfio_file_iommu_group-stub-to-fudge-around.patch
new file mode 100644 (file)
index 0000000..c0a61d9
--- /dev/null
@@ -0,0 +1,94 @@
+From 527552028ebca1cba0848b40b71ff6c9346ff6a8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 29 Nov 2023 16:10:00 -0800
+Subject: vfio: Drop vfio_file_iommu_group() stub to fudge around a KVM wart
+
+From: Sean Christopherson <seanjc@google.com>
+
+[ Upstream commit 4ea95c04fa6b9043a1a301240996aeebe3cb28ec ]
+
+Drop the vfio_file_iommu_group() stub and instead unconditionally declare
+the function to fudge around a KVM wart where KVM tries to do symbol_get()
+on vfio_file_iommu_group() (and other VFIO symbols) even if CONFIG_VFIO=n.
+
+Ensuring the symbol is always declared fixes a PPC build error when
+modules are also disabled, in which case symbol_get() simply points at the
+address of the symbol (with some attributes shenanigans).  Because KVM
+does symbol_get() instead of directly depending on VFIO, the lack of a
+fully defined symbol is not problematic (ugly, but "fine").
+
+   arch/powerpc/kvm/../../../virt/kvm/vfio.c:89:7:
+   error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
+           fn = symbol_get(vfio_file_iommu_group);
+                ^
+   include/linux/module.h:805:60: note: expanded from macro 'symbol_get'
+   #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak,visibility("hidden"))); &(x); })
+                                                              ^
+   include/linux/vfio.h:294:35: note: previous definition is here
+   static inline struct iommu_group *vfio_file_iommu_group(struct file *file)
+                                     ^
+   arch/powerpc/kvm/../../../virt/kvm/vfio.c:89:7:
+   error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
+           fn = symbol_get(vfio_file_iommu_group);
+                ^
+   include/linux/module.h:805:65: note: expanded from macro 'symbol_get'
+   #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak,visibility("hidden"))); &(x); })
+                                                                   ^
+   include/linux/vfio.h:294:35: note: previous definition is here
+   static inline struct iommu_group *vfio_file_iommu_group(struct file *file)
+                                     ^
+   2 errors generated.
+
+Although KVM is firmly in the wrong (there is zero reason for KVM to build
+virt/kvm/vfio.c when VFIO is disabled), fudge around the error in VFIO as
+the stub is unnecessary and doesn't serve its intended purpose (KVM is the
+only external user of vfio_file_iommu_group()), and there is an in-flight
+series to clean up the entire KVM<->VFIO interaction, i.e. fixing this in
+KVM would result in more churn in the long run, and the stub needs to go
+away regardless.
+
+Reported-by: kernel test robot <lkp@intel.com>
+Closes: https://lore.kernel.org/oe-kbuild-all/202308251949.5IiaV0sz-lkp@intel.com
+Closes: https://lore.kernel.org/oe-kbuild-all/202309030741.82aLACDG-lkp@intel.com
+Closes: https://lore.kernel.org/oe-kbuild-all/202309110914.QLH0LU6L-lkp@intel.com
+Link: https://lore.kernel.org/all/0-v1-08396538817d+13c5-vfio_kvm_kconfig_jgg@nvidia.com
+Link: https://lore.kernel.org/all/20230916003118.2540661-1-seanjc@google.com
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Jason Gunthorpe <jgg@nvidia.com>
+Tested-by: Michael Ellerman <mpe@ellerman.id.au>
+Fixes: c1cce6d079b8 ("vfio: Compile vfio_group infrastructure optionally")
+Signed-off-by: Sean Christopherson <seanjc@google.com>
+Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
+Link: https://lore.kernel.org/r/20231130001000.543240-1-seanjc@google.com
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/vfio.h | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/include/linux/vfio.h b/include/linux/vfio.h
+index 454e9295970c4..a65b2513f8cdc 100644
+--- a/include/linux/vfio.h
++++ b/include/linux/vfio.h
+@@ -289,16 +289,12 @@ void vfio_combine_iova_ranges(struct rb_root_cached *root, u32 cur_nodes,
+ /*
+  * External user API
+  */
+-#if IS_ENABLED(CONFIG_VFIO_GROUP)
+ struct iommu_group *vfio_file_iommu_group(struct file *file);
++
++#if IS_ENABLED(CONFIG_VFIO_GROUP)
+ bool vfio_file_is_group(struct file *file);
+ bool vfio_file_has_dev(struct file *file, struct vfio_device *device);
+ #else
+-static inline struct iommu_group *vfio_file_iommu_group(struct file *file)
+-{
+-      return NULL;
+-}
+-
+ static inline bool vfio_file_is_group(struct file *file)
+ {
+       return false;
+-- 
+2.42.0
+
diff --git a/queue-6.6/vfio-pds-fix-mutex-lock-magic-lock-warning.patch b/queue-6.6/vfio-pds-fix-mutex-lock-magic-lock-warning.patch
new file mode 100644 (file)
index 0000000..1ed1102
--- /dev/null
@@ -0,0 +1,111 @@
+From 3324fa27108d62221c399daecbff3dd9c5c39312 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Nov 2023 11:25:31 -0800
+Subject: vfio/pds: Fix mutex lock->magic != lock warning
+
+From: Brett Creeley <brett.creeley@amd.com>
+
+[ Upstream commit 91aeb563bd4332e2988f8c0f64f125c4ecb5bcb3 ]
+
+The following BUG was found when running on a kernel with
+CONFIG_DEBUG_MUTEXES=y set:
+
+DEBUG_LOCKS_WARN_ON(lock->magic != lock)
+RIP: 0010:mutex_trylock+0x10d/0x120
+Call Trace:
+ <TASK>
+ ? __warn+0x85/0x140
+ ? mutex_trylock+0x10d/0x120
+ ? report_bug+0xfc/0x1e0
+ ? handle_bug+0x3f/0x70
+ ? exc_invalid_op+0x17/0x70
+ ? asm_exc_invalid_op+0x1a/0x20
+ ? mutex_trylock+0x10d/0x120
+ ? mutex_trylock+0x10d/0x120
+ pds_vfio_reset+0x3a/0x60 [pds_vfio_pci]
+ pci_reset_function+0x4b/0x70
+ reset_store+0x5b/0xa0
+ kernfs_fop_write_iter+0x137/0x1d0
+ vfs_write+0x2de/0x410
+ ksys_write+0x5d/0xd0
+ do_syscall_64+0x3b/0x90
+ entry_SYSCALL_64_after_hwframe+0x6e/0xd8
+
+As shown, lock->magic != lock. This is because
+mutex_init(&pds_vfio->state_mutex) is called in the VFIO open path. So,
+if a reset is initiated before the VFIO device is opened the mutex will
+have never been initialized. Fix this by calling
+mutex_init(&pds_vfio->state_mutex) in the VFIO init path.
+
+Also, don't destroy the mutex on close because the device may
+be re-opened, which would cause mutex to be uninitialized. Fix this by
+implementing a driver specific vfio_device_ops.release callback that
+destroys the mutex before calling vfio_pci_core_release_dev().
+
+Fixes: bb500dbe2ac6 ("vfio/pds: Add VFIO live migration support")
+Signed-off-by: Brett Creeley <brett.creeley@amd.com>
+Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
+Link: https://lore.kernel.org/r/20231122192532.25791-2-brett.creeley@amd.com
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/vfio/pci/pds/vfio_dev.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/vfio/pci/pds/vfio_dev.c b/drivers/vfio/pci/pds/vfio_dev.c
+index 649b18ee394bb..8c9fb87b13e1d 100644
+--- a/drivers/vfio/pci/pds/vfio_dev.c
++++ b/drivers/vfio/pci/pds/vfio_dev.c
+@@ -155,6 +155,8 @@ static int pds_vfio_init_device(struct vfio_device *vdev)
+       pds_vfio->vf_id = vf_id;
++      mutex_init(&pds_vfio->state_mutex);
++
+       vdev->migration_flags = VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P;
+       vdev->mig_ops = &pds_vfio_lm_ops;
+       vdev->log_ops = &pds_vfio_log_ops;
+@@ -168,6 +170,16 @@ static int pds_vfio_init_device(struct vfio_device *vdev)
+       return 0;
+ }
++static void pds_vfio_release_device(struct vfio_device *vdev)
++{
++      struct pds_vfio_pci_device *pds_vfio =
++              container_of(vdev, struct pds_vfio_pci_device,
++                           vfio_coredev.vdev);
++
++      mutex_destroy(&pds_vfio->state_mutex);
++      vfio_pci_core_release_dev(vdev);
++}
++
+ static int pds_vfio_open_device(struct vfio_device *vdev)
+ {
+       struct pds_vfio_pci_device *pds_vfio =
+@@ -179,7 +191,6 @@ static int pds_vfio_open_device(struct vfio_device *vdev)
+       if (err)
+               return err;
+-      mutex_init(&pds_vfio->state_mutex);
+       pds_vfio->state = VFIO_DEVICE_STATE_RUNNING;
+       pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
+@@ -199,14 +210,13 @@ static void pds_vfio_close_device(struct vfio_device *vdev)
+       pds_vfio_put_save_file(pds_vfio);
+       pds_vfio_dirty_disable(pds_vfio, true);
+       mutex_unlock(&pds_vfio->state_mutex);
+-      mutex_destroy(&pds_vfio->state_mutex);
+       vfio_pci_core_close_device(vdev);
+ }
+ static const struct vfio_device_ops pds_vfio_ops = {
+       .name = "pds-vfio",
+       .init = pds_vfio_init_device,
+-      .release = vfio_pci_core_release_dev,
++      .release = pds_vfio_release_device,
+       .open_device = pds_vfio_open_device,
+       .close_device = pds_vfio_close_device,
+       .ioctl = vfio_pci_core_ioctl,
+-- 
+2.42.0
+
diff --git a/queue-6.6/vfio-pds-fix-possible-sleep-while-in-atomic-context.patch b/queue-6.6/vfio-pds-fix-possible-sleep-while-in-atomic-context.patch
new file mode 100644 (file)
index 0000000..147ae56
--- /dev/null
@@ -0,0 +1,151 @@
+From d223bcc6cae7ee99296be2d5e969b2d07e92f00c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Nov 2023 11:25:32 -0800
+Subject: vfio/pds: Fix possible sleep while in atomic context
+
+From: Brett Creeley <brett.creeley@amd.com>
+
+[ Upstream commit ae2667cd8a479bb5abd6e24c12fcc9ef5bc06d75 ]
+
+The driver could possibly sleep while in atomic context resulting
+in the following call trace while CONFIG_DEBUG_ATOMIC_SLEEP=y is
+set:
+
+BUG: sleeping function called from invalid context at kernel/locking/mutex.c:283
+in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 2817, name: bash
+preempt_count: 1, expected: 0
+RCU nest depth: 0, expected: 0
+Call Trace:
+ <TASK>
+ dump_stack_lvl+0x36/0x50
+ __might_resched+0x123/0x170
+ mutex_lock+0x1e/0x50
+ pds_vfio_put_lm_file+0x1e/0xa0 [pds_vfio_pci]
+ pds_vfio_put_save_file+0x19/0x30 [pds_vfio_pci]
+ pds_vfio_state_mutex_unlock+0x2e/0x80 [pds_vfio_pci]
+ pci_reset_function+0x4b/0x70
+ reset_store+0x5b/0xa0
+ kernfs_fop_write_iter+0x137/0x1d0
+ vfs_write+0x2de/0x410
+ ksys_write+0x5d/0xd0
+ do_syscall_64+0x3b/0x90
+ entry_SYSCALL_64_after_hwframe+0x6e/0xd8
+
+This can happen if pds_vfio_put_restore_file() and/or
+pds_vfio_put_save_file() grab the mutex_lock(&lm_file->lock)
+while the spin_lock(&pds_vfio->reset_lock) is held, which can
+happen during while calling pds_vfio_state_mutex_unlock().
+
+Fix this by changing the reset_lock to reset_mutex so there are no such
+conerns. Also, make sure to destroy the reset_mutex in the driver specific
+VFIO device release function.
+
+This also fixes a spinlock bad magic BUG that was caused
+by not calling spinlock_init() on the reset_lock. Since, the lock is
+being changed to a mutex, make sure to call mutex_init() on it.
+
+Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
+Closes: https://lore.kernel.org/kvm/1f9bc27b-3de9-4891-9687-ba2820c1b390@moroto.mountain/
+Fixes: bb500dbe2ac6 ("vfio/pds: Add VFIO live migration support")
+Signed-off-by: Brett Creeley <brett.creeley@amd.com>
+Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
+Link: https://lore.kernel.org/r/20231122192532.25791-3-brett.creeley@amd.com
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/vfio/pci/pds/pci_drv.c  |  4 ++--
+ drivers/vfio/pci/pds/vfio_dev.c | 14 ++++++++------
+ drivers/vfio/pci/pds/vfio_dev.h |  2 +-
+ 3 files changed, 11 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/vfio/pci/pds/pci_drv.c b/drivers/vfio/pci/pds/pci_drv.c
+index ab4b5958e4131..caffa1a2cf591 100644
+--- a/drivers/vfio/pci/pds/pci_drv.c
++++ b/drivers/vfio/pci/pds/pci_drv.c
+@@ -55,10 +55,10 @@ static void pds_vfio_recovery(struct pds_vfio_pci_device *pds_vfio)
+        * VFIO_DEVICE_STATE_RUNNING.
+        */
+       if (deferred_reset_needed) {
+-              spin_lock(&pds_vfio->reset_lock);
++              mutex_lock(&pds_vfio->reset_mutex);
+               pds_vfio->deferred_reset = true;
+               pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_ERROR;
+-              spin_unlock(&pds_vfio->reset_lock);
++              mutex_unlock(&pds_vfio->reset_mutex);
+       }
+ }
+diff --git a/drivers/vfio/pci/pds/vfio_dev.c b/drivers/vfio/pci/pds/vfio_dev.c
+index 8c9fb87b13e1d..4c351c59d05a9 100644
+--- a/drivers/vfio/pci/pds/vfio_dev.c
++++ b/drivers/vfio/pci/pds/vfio_dev.c
+@@ -29,7 +29,7 @@ struct pds_vfio_pci_device *pds_vfio_pci_drvdata(struct pci_dev *pdev)
+ void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio)
+ {
+ again:
+-      spin_lock(&pds_vfio->reset_lock);
++      mutex_lock(&pds_vfio->reset_mutex);
+       if (pds_vfio->deferred_reset) {
+               pds_vfio->deferred_reset = false;
+               if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) {
+@@ -39,23 +39,23 @@ void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio)
+               }
+               pds_vfio->state = pds_vfio->deferred_reset_state;
+               pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
+-              spin_unlock(&pds_vfio->reset_lock);
++              mutex_unlock(&pds_vfio->reset_mutex);
+               goto again;
+       }
+       mutex_unlock(&pds_vfio->state_mutex);
+-      spin_unlock(&pds_vfio->reset_lock);
++      mutex_unlock(&pds_vfio->reset_mutex);
+ }
+ void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio)
+ {
+-      spin_lock(&pds_vfio->reset_lock);
++      mutex_lock(&pds_vfio->reset_mutex);
+       pds_vfio->deferred_reset = true;
+       pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
+       if (!mutex_trylock(&pds_vfio->state_mutex)) {
+-              spin_unlock(&pds_vfio->reset_lock);
++              mutex_unlock(&pds_vfio->reset_mutex);
+               return;
+       }
+-      spin_unlock(&pds_vfio->reset_lock);
++      mutex_unlock(&pds_vfio->reset_mutex);
+       pds_vfio_state_mutex_unlock(pds_vfio);
+ }
+@@ -156,6 +156,7 @@ static int pds_vfio_init_device(struct vfio_device *vdev)
+       pds_vfio->vf_id = vf_id;
+       mutex_init(&pds_vfio->state_mutex);
++      mutex_init(&pds_vfio->reset_mutex);
+       vdev->migration_flags = VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P;
+       vdev->mig_ops = &pds_vfio_lm_ops;
+@@ -177,6 +178,7 @@ static void pds_vfio_release_device(struct vfio_device *vdev)
+                            vfio_coredev.vdev);
+       mutex_destroy(&pds_vfio->state_mutex);
++      mutex_destroy(&pds_vfio->reset_mutex);
+       vfio_pci_core_release_dev(vdev);
+ }
+diff --git a/drivers/vfio/pci/pds/vfio_dev.h b/drivers/vfio/pci/pds/vfio_dev.h
+index b8f2d667608f3..e7b01080a1ec3 100644
+--- a/drivers/vfio/pci/pds/vfio_dev.h
++++ b/drivers/vfio/pci/pds/vfio_dev.h
+@@ -18,7 +18,7 @@ struct pds_vfio_pci_device {
+       struct pds_vfio_dirty dirty;
+       struct mutex state_mutex; /* protect migration state */
+       enum vfio_device_mig_state state;
+-      spinlock_t reset_lock; /* protect reset_done flow */
++      struct mutex reset_mutex; /* protect reset_done flow */
+       u8 deferred_reset;
+       enum vfio_device_mig_state deferred_reset_state;
+       struct notifier_block nb;
+-- 
+2.42.0
+
diff --git a/queue-6.6/x86-xen-fix-percpu-vcpu_info-allocation.patch b/queue-6.6/x86-xen-fix-percpu-vcpu_info-allocation.patch
new file mode 100644 (file)
index 0000000..3f3292c
--- /dev/null
@@ -0,0 +1,71 @@
+From abbbb744e94419239d3c6cd9cc13b6fa3cd703bb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Nov 2023 08:48:52 +0100
+Subject: x86/xen: fix percpu vcpu_info allocation
+
+From: Juergen Gross <jgross@suse.com>
+
+[ Upstream commit db2832309a82b9acc4b8cc33a1831d36507ec13e ]
+
+Today the percpu struct vcpu_info is allocated via DEFINE_PER_CPU(),
+meaning that it could cross a page boundary. In this case registering
+it with the hypervisor will fail, resulting in a panic().
+
+This can easily be fixed by using DEFINE_PER_CPU_ALIGNED() instead,
+as struct vcpu_info is guaranteed to have a size of 64 bytes, matching
+the cache line size of x86 64-bit processors (Xen doesn't support
+32-bit processors).
+
+Fixes: 5ead97c84fa7 ("xen: Core Xen implementation")
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.con>
+Link: https://lore.kernel.org/r/20231124074852.25161-1-jgross@suse.com
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/xen/enlighten.c | 6 +++++-
+ arch/x86/xen/xen-ops.h   | 2 +-
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
+index 0337392a31214..3c61bb98c10e2 100644
+--- a/arch/x86/xen/enlighten.c
++++ b/arch/x86/xen/enlighten.c
+@@ -33,9 +33,12 @@ EXPORT_SYMBOL_GPL(hypercall_page);
+  * and xen_vcpu_setup for details. By default it points to share_info->vcpu_info
+  * but during boot it is switched to point to xen_vcpu_info.
+  * The pointer is used in xen_evtchn_do_upcall to acknowledge pending events.
++ * Make sure that xen_vcpu_info doesn't cross a page boundary by making it
++ * cache-line aligned (the struct is guaranteed to have a size of 64 bytes,
++ * which matches the cache line size of 64-bit x86 processors).
+  */
+ DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
+-DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
++DEFINE_PER_CPU_ALIGNED(struct vcpu_info, xen_vcpu_info);
+ /* Linux <-> Xen vCPU id mapping */
+ DEFINE_PER_CPU(uint32_t, xen_vcpu_id);
+@@ -160,6 +163,7 @@ void xen_vcpu_setup(int cpu)
+       int err;
+       struct vcpu_info *vcpup;
++      BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
+       BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
+       /*
+diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
+index 408a2aa66c692..a87ab36889e76 100644
+--- a/arch/x86/xen/xen-ops.h
++++ b/arch/x86/xen/xen-ops.h
+@@ -21,7 +21,7 @@ extern void *xen_initial_gdt;
+ struct trap_info;
+ void xen_copy_trap_info(struct trap_info *traps);
+-DECLARE_PER_CPU(struct vcpu_info, xen_vcpu_info);
++DECLARE_PER_CPU_ALIGNED(struct vcpu_info, xen_vcpu_info);
+ DECLARE_PER_CPU(unsigned long, xen_cr3);
+ DECLARE_PER_CPU(unsigned long, xen_current_cr3);
+-- 
+2.42.0
+