@@ -3011,27 +3011,52 @@ unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
3011
3011
return regs -> ip + code_segment_base (regs );
3012
3012
}
3013
3013
3014
- unsigned long perf_arch_misc_flags (struct pt_regs * regs )
3014
+ static unsigned long common_misc_flags (struct pt_regs * regs )
3015
3015
{
3016
- unsigned int guest_state = perf_guest_state ();
3017
- int misc = 0 ;
3016
+ if ( regs -> flags & PERF_EFLAGS_EXACT )
3017
+ return PERF_RECORD_MISC_EXACT_IP ;
3018
3018
3019
- if (guest_state ) {
3020
- if (guest_state & PERF_GUEST_USER )
3021
- misc |= PERF_RECORD_MISC_GUEST_USER ;
3022
- else
3023
- misc |= PERF_RECORD_MISC_GUEST_KERNEL ;
3024
- } else {
3025
- if (user_mode (regs ))
3026
- misc |= PERF_RECORD_MISC_USER ;
3027
- else
3028
- misc |= PERF_RECORD_MISC_KERNEL ;
3029
- }
3019
+ return 0 ;
3020
+ }
3030
3021
3031
- if (regs -> flags & PERF_EFLAGS_EXACT )
3032
- misc |= PERF_RECORD_MISC_EXACT_IP ;
3022
+ static unsigned long guest_misc_flags (struct pt_regs * regs )
3023
+ {
3024
+ unsigned long guest_state = perf_guest_state ();
3025
+
3026
+ if (!(guest_state & PERF_GUEST_ACTIVE ))
3027
+ return 0 ;
3028
+
3029
+ if (guest_state & PERF_GUEST_USER )
3030
+ return PERF_RECORD_MISC_GUEST_USER ;
3031
+ else
3032
+ return PERF_RECORD_MISC_GUEST_KERNEL ;
3033
+
3034
+ }
3035
+
3036
+ static unsigned long host_misc_flags (struct pt_regs * regs )
3037
+ {
3038
+ if (user_mode (regs ))
3039
+ return PERF_RECORD_MISC_USER ;
3040
+ else
3041
+ return PERF_RECORD_MISC_KERNEL ;
3042
+ }
3043
+
3044
+ unsigned long perf_arch_guest_misc_flags (struct pt_regs * regs )
3045
+ {
3046
+ unsigned long flags = common_misc_flags (regs );
3047
+
3048
+ flags |= guest_misc_flags (regs );
3049
+
3050
+ return flags ;
3051
+ }
3052
+
3053
+ unsigned long perf_arch_misc_flags (struct pt_regs * regs )
3054
+ {
3055
+ unsigned long flags = common_misc_flags (regs );
3056
+
3057
+ flags |= host_misc_flags (regs );
3033
3058
3034
- return misc ;
3059
+ return flags ;
3035
3060
}
3036
3061
3037
3062
void perf_get_x86_pmu_capability (struct x86_pmu_capability * cap )
0 commit comments