Skip to content

Commit 73924ec

Browse files
pa1guptatorvalds
authored andcommitted
x86/pm: Save the MSR validity status at context setup
The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be. Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend. Fixes: 7a9c2dd ("x86/pm: Introduce quirk framework to save/restore extra MSR registers around suspend/resume") Suggested-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Borislav Petkov <bp@suse.de> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ce4c854 commit 73924ec

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

arch/x86/power/cpu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ static void msr_save_context(struct saved_context *ctxt)
4040
struct saved_msr *end = msr + ctxt->saved_msrs.num;
4141

4242
while (msr < end) {
43-
msr->valid = !rdmsrl_safe(msr->info.msr_no, &msr->info.reg.q);
43+
if (msr->valid)
44+
rdmsrl(msr->info.msr_no, msr->info.reg.q);
4445
msr++;
4546
}
4647
}
@@ -424,8 +425,10 @@ static int msr_build_context(const u32 *msr_id, const int num)
424425
}
425426

426427
for (i = saved_msrs->num, j = 0; i < total_num; i++, j++) {
428+
u64 dummy;
429+
427430
msr_array[i].info.msr_no = msr_id[j];
428-
msr_array[i].valid = false;
431+
msr_array[i].valid = !rdmsrl_safe(msr_id[j], &dummy);
429432
msr_array[i].info.reg.q = 0;
430433
}
431434
saved_msrs->num = total_num;

0 commit comments

Comments
 (0)