mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/traps: const-correctness for IST handlers
NMI and MCE interrupt handlers have no right to modify their exception frame or underlying vcpu registers. Apply liberal quantities of 'const' to 'struct cpu_user_regs *' throughout the codebase. The Double Fault handler, while an IST handler, reloads some extra architectural state back into its regs parameter. As this is for printing purposes and on a terminal error path, the const requirements for #DF are relaxed. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
9921387f0c
commit
b6100a6cd5
21 files changed
+59
-52
No files matched your search
@@ -78,7 +78,7 @@ static const unsigned char * const p6_nops[ASM_NOP_MAX+1] /*__initconst*/ = {
|
||||
|
||||
static const unsigned char * const *ideal_nops __initdata = k8_nops;
|
||||
|
||||
static int __init mask_nmi_callback(struct cpu_user_regs *regs, int cpu)
|
||||
static int __init mask_nmi_callback(const struct cpu_user_regs *regs, int cpu)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void mce_register_addrcheck(mce_check_addr_t cbfunc)
|
||||
void
|
||||
mc_memerr_dhandler(struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs)
|
||||
const struct cpu_user_regs *regs)
|
||||
{
|
||||
struct mcinfo_bank *bank = binfo->mib;
|
||||
struct mcinfo_global *global = binfo->mig;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
void
|
||||
mc_memerr_dhandler(struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs);
|
||||
const struct cpu_user_regs *regs);
|
||||
|
||||
#define MC_ADDR_PHYSICAL 0
|
||||
#define MC_ADDR_VIRTUAL 1
|
||||
|
||||
@@ -70,7 +70,7 @@ static void __init mce_set_verbosity(char *str)
|
||||
custom_param("mce_verbosity", mce_set_verbosity);
|
||||
|
||||
/* Handle unconfigured int18 (should never happen) */
|
||||
static void unexpected_machine_check(struct cpu_user_regs *regs, long error_code)
|
||||
static void unexpected_machine_check(const struct cpu_user_regs *regs, long error_code)
|
||||
{
|
||||
console_force_unlock();
|
||||
printk("Unexpected Machine Check Exception\n");
|
||||
@@ -88,7 +88,7 @@ void x86_mce_vector_register(x86_mce_vector_t hdlr)
|
||||
|
||||
/* Call the installed machine check handler for this CPU setup. */
|
||||
|
||||
void machine_check_vector(struct cpu_user_regs *regs, long error_code)
|
||||
void machine_check_vector(const struct cpu_user_regs *regs, long error_code)
|
||||
{
|
||||
_machine_check_vector(regs, error_code);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ static void mce_spin_unlock(spinlock_t *lk)
|
||||
spin_unlock(lk);
|
||||
}
|
||||
|
||||
static enum mce_result mce_action(struct cpu_user_regs *regs,
|
||||
static enum mce_result mce_action(const struct cpu_user_regs *regs,
|
||||
mctelem_cookie_t mctc);
|
||||
|
||||
/*
|
||||
@@ -432,7 +432,7 @@ static enum mce_result mce_action(struct cpu_user_regs *regs,
|
||||
* -1: if system can't be recovered
|
||||
* 0: Continue to next step
|
||||
*/
|
||||
static int mce_urgent_action(struct cpu_user_regs *regs,
|
||||
static int mce_urgent_action(const struct cpu_user_regs *regs,
|
||||
mctelem_cookie_t mctc)
|
||||
{
|
||||
uint64_t gstatus;
|
||||
@@ -459,7 +459,7 @@ static int mce_urgent_action(struct cpu_user_regs *regs,
|
||||
}
|
||||
|
||||
/* Shared #MC handler. */
|
||||
void mcheck_cmn_handler(struct cpu_user_regs *regs, long error_code,
|
||||
void mcheck_cmn_handler(const struct cpu_user_regs *regs, long error_code,
|
||||
struct mca_banks *bankmask, struct mca_banks *clear_bank)
|
||||
{
|
||||
uint64_t gstatus;
|
||||
@@ -1570,7 +1570,7 @@ void mc_panic(char *s)
|
||||
*/
|
||||
|
||||
/* Maybe called in MCE context, no lock, no printk */
|
||||
static enum mce_result mce_action(struct cpu_user_regs *regs,
|
||||
static enum mce_result mce_action(const struct cpu_user_regs *regs,
|
||||
mctelem_cookie_t mctc)
|
||||
{
|
||||
struct mc_info *local_mi;
|
||||
|
||||
@@ -62,12 +62,12 @@ void x86_mc_get_cpu_info(unsigned, uint32_t *, uint16_t *, uint16_t *,
|
||||
uint32_t *, uint32_t *, uint32_t *, uint32_t *);
|
||||
|
||||
/* Register a handler for machine check exceptions. */
|
||||
typedef void (*x86_mce_vector_t)(struct cpu_user_regs *, long);
|
||||
typedef void (*x86_mce_vector_t)(const struct cpu_user_regs *, long);
|
||||
extern void x86_mce_vector_register(x86_mce_vector_t);
|
||||
|
||||
/* Common generic MCE handler that implementations may nominate
|
||||
* via x86_mce_vector_register. */
|
||||
extern void mcheck_cmn_handler(struct cpu_user_regs *, long,
|
||||
extern void mcheck_cmn_handler(const struct cpu_user_regs *, long,
|
||||
struct mca_banks *, struct mca_banks *);
|
||||
|
||||
/* Register a handler for judging whether mce is recoverable. */
|
||||
|
||||
@@ -242,7 +242,7 @@ amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status)
|
||||
}
|
||||
|
||||
/* Common AMD Machine Check Handler for AMD K8 and higher */
|
||||
static void amd_cmn_machine_check(struct cpu_user_regs *regs, long error_code)
|
||||
static void amd_cmn_machine_check(const struct cpu_user_regs *regs, long error_code)
|
||||
{
|
||||
mcheck_cmn_handler(regs, error_code, mca_allbanks,
|
||||
__get_cpu_var(mce_clear_banks));
|
||||
|
||||
@@ -258,7 +258,7 @@ static enum intel_mce_type intel_check_mce_type(uint64_t status)
|
||||
static void intel_memerr_dhandler(
|
||||
struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs)
|
||||
const struct cpu_user_regs *regs)
|
||||
{
|
||||
mce_printk(MCE_VERBOSE, "MCE: Enter UCR recovery action\n");
|
||||
mc_memerr_dhandler(binfo, result, regs);
|
||||
@@ -285,7 +285,7 @@ static int intel_checkaddr(uint64_t status, uint64_t misc, int addrtype)
|
||||
static void intel_srar_dhandler(
|
||||
struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs)
|
||||
const struct cpu_user_regs *regs)
|
||||
{
|
||||
uint64_t status = binfo->mib->mc_status;
|
||||
|
||||
@@ -311,7 +311,7 @@ static int intel_srao_check(uint64_t status)
|
||||
static void intel_srao_dhandler(
|
||||
struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs)
|
||||
const struct cpu_user_regs *regs)
|
||||
{
|
||||
uint64_t status = binfo->mib->mc_status;
|
||||
|
||||
@@ -340,7 +340,7 @@ static int intel_default_check(uint64_t status)
|
||||
static void intel_default_mce_dhandler(
|
||||
struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs * regs)
|
||||
const struct cpu_user_regs * regs)
|
||||
{
|
||||
uint64_t status = binfo->mib->mc_status;
|
||||
enum intel_mce_type type;
|
||||
@@ -362,7 +362,7 @@ static const struct mca_error_handler intel_mce_dhandlers[] = {
|
||||
static void intel_default_mce_uhandler(
|
||||
struct mca_binfo *binfo,
|
||||
enum mce_result *result,
|
||||
struct cpu_user_regs *regs)
|
||||
const struct cpu_user_regs *regs)
|
||||
{
|
||||
uint64_t status = binfo->mib->mc_status;
|
||||
enum intel_mce_type type;
|
||||
@@ -384,7 +384,7 @@ static const struct mca_error_handler intel_mce_uhandlers[] = {
|
||||
{intel_default_check, intel_default_mce_uhandler}
|
||||
};
|
||||
|
||||
static void intel_machine_check(struct cpu_user_regs * regs, long error_code)
|
||||
static void intel_machine_check(const struct cpu_user_regs * regs, long error_code)
|
||||
{
|
||||
mcheck_cmn_handler(regs, error_code, mca_allbanks,
|
||||
__get_cpu_var(mce_clear_banks));
|
||||
|
||||
@@ -152,7 +152,7 @@ struct mca_error_handler
|
||||
*/
|
||||
int (*owned_error)(uint64_t status);
|
||||
void (*recovery_handler)(struct mca_binfo *binfo,
|
||||
enum mce_result *result, struct cpu_user_regs *regs);
|
||||
enum mce_result *result, const struct cpu_user_regs *regs);
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
|
||||
+1
-1
@@ -432,7 +432,7 @@ int __init watchdog_setup(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nmi_watchdog_tick(struct cpu_user_regs * regs)
|
||||
void nmi_watchdog_tick(const struct cpu_user_regs *regs)
|
||||
{
|
||||
unsigned int sum = this_cpu(nmi_timer_ticks);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ void passive_domain_destroy(struct vcpu *v)
|
||||
model->free_msr(v);
|
||||
}
|
||||
|
||||
static int nmi_callback(struct cpu_user_regs *regs, int cpu)
|
||||
static int nmi_callback(const struct cpu_user_regs *regs, int cpu)
|
||||
{
|
||||
int xen_mode, ovf;
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ static void athlon_setup_ctrs(struct op_msrs const * const msrs)
|
||||
}
|
||||
|
||||
static inline void
|
||||
ibs_log_event(u64 data, struct cpu_user_regs * const regs, int mode)
|
||||
ibs_log_event(u64 data, struct cpu_user_regs const * const regs, int mode)
|
||||
{
|
||||
struct vcpu *v = current;
|
||||
u32 temp = 0;
|
||||
@@ -250,7 +250,7 @@ ibs_log_event(u64 data, struct cpu_user_regs * const regs, int mode)
|
||||
|
||||
}
|
||||
|
||||
static inline int handle_ibs(int mode, struct cpu_user_regs * const regs)
|
||||
static inline int handle_ibs(int mode, struct cpu_user_regs const * const regs)
|
||||
{
|
||||
u64 val, ctl;
|
||||
struct vcpu *v = current;
|
||||
@@ -310,7 +310,7 @@ static inline int handle_ibs(int mode, struct cpu_user_regs * const regs)
|
||||
|
||||
static int athlon_check_ctrs(unsigned int const cpu,
|
||||
struct op_msrs const * const msrs,
|
||||
struct cpu_user_regs * const regs)
|
||||
struct cpu_user_regs const * const regs)
|
||||
|
||||
{
|
||||
uint64_t msr_content;
|
||||
|
||||
@@ -611,7 +611,7 @@ static void p4_setup_ctrs(struct op_msrs const * const msrs)
|
||||
|
||||
static int p4_check_ctrs(unsigned int const cpu,
|
||||
struct op_msrs const * const msrs,
|
||||
struct cpu_user_regs * const regs)
|
||||
struct cpu_user_regs const * const regs)
|
||||
{
|
||||
unsigned long ctr, stag, real;
|
||||
uint64_t msr_content;
|
||||
|
||||
@@ -126,7 +126,7 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs)
|
||||
|
||||
static int ppro_check_ctrs(unsigned int const cpu,
|
||||
struct op_msrs const * const msrs,
|
||||
struct cpu_user_regs * const regs)
|
||||
struct cpu_user_regs const * const regs)
|
||||
{
|
||||
u64 val;
|
||||
int i;
|
||||
|
||||
@@ -33,7 +33,7 @@ struct op_x86_model_spec {
|
||||
void (*setup_ctrs)(struct op_msrs const * const msrs);
|
||||
int (*check_ctrs)(unsigned int const cpu,
|
||||
struct op_msrs const * const msrs,
|
||||
struct cpu_user_regs * const regs);
|
||||
struct cpu_user_regs const * const regs);
|
||||
void (*start)(struct op_msrs const * const msrs);
|
||||
void (*stop)(struct op_msrs const * const msrs);
|
||||
int (*is_arch_pmu_msr)(u64 msr_index, int *type, int *index);
|
||||
|
||||
+10
-10
@@ -114,7 +114,7 @@ boolean_param("ler", opt_ler);
|
||||
#define stack_words_per_line 4
|
||||
#define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)regs->rsp)
|
||||
|
||||
static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs)
|
||||
static void show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long *stack, addr;
|
||||
@@ -290,7 +290,7 @@ static void show_trace(const struct cpu_user_regs *regs)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
void show_stack(struct cpu_user_regs *regs)
|
||||
void show_stack(const struct cpu_user_regs *regs)
|
||||
{
|
||||
unsigned long *stack = ESP_BEFORE_EXCEPTION(regs), addr;
|
||||
int i;
|
||||
@@ -349,7 +349,7 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs)
|
||||
#endif
|
||||
}
|
||||
|
||||
void show_execution_state(struct cpu_user_regs *regs)
|
||||
void show_execution_state(const struct cpu_user_regs *regs)
|
||||
{
|
||||
show_registers(regs);
|
||||
show_stack(regs);
|
||||
@@ -394,7 +394,7 @@ static const char *trapstr(unsigned int trapnr)
|
||||
* are disabled). In such situations we can't do much that is safe. We try to
|
||||
* print out some tracing and then we just spin.
|
||||
*/
|
||||
void fatal_trap(int trapnr, struct cpu_user_regs *regs)
|
||||
void fatal_trap(int trapnr, const struct cpu_user_regs *regs)
|
||||
{
|
||||
static DEFINE_PER_CPU(char, depth);
|
||||
|
||||
@@ -1086,7 +1086,7 @@ void do_int3(struct cpu_user_regs *regs)
|
||||
do_guest_trap(TRAP_int3, regs, 0);
|
||||
}
|
||||
|
||||
void do_machine_check(struct cpu_user_regs *regs)
|
||||
void do_machine_check(const struct cpu_user_regs *regs)
|
||||
{
|
||||
machine_check_vector(regs, regs->error_code);
|
||||
}
|
||||
@@ -3240,7 +3240,7 @@ static void nmi_hwdom_report(unsigned int reason_idx)
|
||||
send_guest_trap(d, 0, TRAP_nmi);
|
||||
}
|
||||
|
||||
static void pci_serr_error(struct cpu_user_regs *regs)
|
||||
static void pci_serr_error(const struct cpu_user_regs *regs)
|
||||
{
|
||||
outb((inb(0x61) & 0x0f) | 0x04, 0x61); /* clear-and-disable the PCI SERR error line. */
|
||||
|
||||
@@ -3260,7 +3260,7 @@ static void pci_serr_error(struct cpu_user_regs *regs)
|
||||
}
|
||||
}
|
||||
|
||||
static void io_check_error(struct cpu_user_regs *regs)
|
||||
static void io_check_error(const struct cpu_user_regs *regs)
|
||||
{
|
||||
switch ( opt_nmi[0] )
|
||||
{
|
||||
@@ -3279,7 +3279,7 @@ static void io_check_error(struct cpu_user_regs *regs)
|
||||
outb((inb(0x61) & 0x07) | 0x00, 0x61); /* enable IOCK */
|
||||
}
|
||||
|
||||
static void unknown_nmi_error(struct cpu_user_regs *regs, unsigned char reason)
|
||||
static void unknown_nmi_error(const struct cpu_user_regs *regs, unsigned char reason)
|
||||
{
|
||||
switch ( opt_nmi[0] )
|
||||
{
|
||||
@@ -3295,14 +3295,14 @@ static void unknown_nmi_error(struct cpu_user_regs *regs, unsigned char reason)
|
||||
}
|
||||
}
|
||||
|
||||
static int dummy_nmi_callback(struct cpu_user_regs *regs, int cpu)
|
||||
static int dummy_nmi_callback(const struct cpu_user_regs *regs, int cpu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static nmi_callback_t nmi_callback = dummy_nmi_callback;
|
||||
|
||||
void do_nmi(struct cpu_user_regs *regs)
|
||||
void do_nmi(const struct cpu_user_regs *regs)
|
||||
{
|
||||
unsigned int cpu = smp_processor_id();
|
||||
unsigned char reason;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <compat/callback.h>
|
||||
#include <compat/arch-x86_32.h>
|
||||
|
||||
void compat_show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs,
|
||||
void compat_show_guest_stack(struct vcpu *v, const struct cpu_user_regs *regs,
|
||||
int debug_stack_lines)
|
||||
{
|
||||
unsigned int i, *stack, addr, mask = STACK_SIZE;
|
||||
|
||||
@@ -79,7 +79,7 @@ static void _show_registers(
|
||||
regs->gs, regs->ss, regs->cs);
|
||||
}
|
||||
|
||||
void show_registers(struct cpu_user_regs *regs)
|
||||
void show_registers(const struct cpu_user_regs *regs)
|
||||
{
|
||||
struct cpu_user_regs fault_regs = *regs;
|
||||
unsigned long fault_crs[8];
|
||||
|
||||
@@ -206,7 +206,7 @@ extern void release_lapic_nmi(void);
|
||||
extern void self_nmi(void);
|
||||
extern void disable_timer_nmi_watchdog(void);
|
||||
extern void enable_timer_nmi_watchdog(void);
|
||||
extern void nmi_watchdog_tick (struct cpu_user_regs *regs);
|
||||
extern void nmi_watchdog_tick (const struct cpu_user_regs *regs);
|
||||
extern int APIC_init_uniprocessor (void);
|
||||
extern void disable_APIC_timer(void);
|
||||
extern void enable_APIC_timer(void);
|
||||
|
||||
@@ -9,7 +9,7 @@ struct cpu_user_regs;
|
||||
/* Watchdog boolean from the command line */
|
||||
extern bool_t opt_watchdog;
|
||||
|
||||
typedef int (*nmi_callback_t)(struct cpu_user_regs *regs, int cpu);
|
||||
typedef int (*nmi_callback_t)(const struct cpu_user_regs *regs, int cpu);
|
||||
|
||||
/**
|
||||
* set_nmi_callback
|
||||
|
||||
@@ -477,27 +477,32 @@ static always_inline void rep_nop(void)
|
||||
|
||||
#define cpu_relax() rep_nop()
|
||||
|
||||
void show_stack(struct cpu_user_regs *regs);
|
||||
void show_stack(const struct cpu_user_regs *regs);
|
||||
void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs);
|
||||
void show_registers(struct cpu_user_regs *regs);
|
||||
void show_execution_state(struct cpu_user_regs *regs);
|
||||
void show_registers(const struct cpu_user_regs *regs);
|
||||
void show_execution_state(const struct cpu_user_regs *regs);
|
||||
#define dump_execution_state() run_in_exception_handler(show_execution_state)
|
||||
void show_page_walk(unsigned long addr);
|
||||
void noreturn fatal_trap(int trapnr, struct cpu_user_regs *regs);
|
||||
void noreturn fatal_trap(int trapnr, const struct cpu_user_regs *regs);
|
||||
|
||||
void compat_show_guest_stack(struct vcpu *, struct cpu_user_regs *, int lines);
|
||||
void compat_show_guest_stack(struct vcpu *v,
|
||||
const struct cpu_user_regs *regs, int lines);
|
||||
|
||||
extern void mtrr_ap_init(void);
|
||||
extern void mtrr_bp_init(void);
|
||||
|
||||
void mcheck_init(struct cpuinfo_x86 *c, bool_t bsp);
|
||||
|
||||
#define DECLARE_TRAP_HANDLER(_name) \
|
||||
void _name(void); \
|
||||
void do_ ## _name(struct cpu_user_regs *regs)
|
||||
#define DECLARE_TRAP_HANDLER(_name) \
|
||||
void _name(void); \
|
||||
void do_ ## _name(struct cpu_user_regs *regs)
|
||||
#define DECLARE_TRAP_HANDLER_CONST(_name) \
|
||||
void _name(void); \
|
||||
void do_ ## _name(const struct cpu_user_regs *regs)
|
||||
|
||||
DECLARE_TRAP_HANDLER(divide_error);
|
||||
DECLARE_TRAP_HANDLER(debug);
|
||||
DECLARE_TRAP_HANDLER(nmi);
|
||||
DECLARE_TRAP_HANDLER_CONST(nmi);
|
||||
DECLARE_TRAP_HANDLER(int3);
|
||||
DECLARE_TRAP_HANDLER(overflow);
|
||||
DECLARE_TRAP_HANDLER(bounds);
|
||||
@@ -512,8 +517,10 @@ DECLARE_TRAP_HANDLER(page_fault);
|
||||
DECLARE_TRAP_HANDLER(early_page_fault);
|
||||
DECLARE_TRAP_HANDLER(coprocessor_error);
|
||||
DECLARE_TRAP_HANDLER(simd_coprocessor_error);
|
||||
DECLARE_TRAP_HANDLER(machine_check);
|
||||
DECLARE_TRAP_HANDLER_CONST(machine_check);
|
||||
DECLARE_TRAP_HANDLER(alignment_check);
|
||||
|
||||
#undef DECLARE_TRAP_HANDLER_CONST
|
||||
#undef DECLARE_TRAP_HANDLER
|
||||
|
||||
void trap_nop(void);
|
||||
|
||||
@@ -28,7 +28,7 @@ struct softirq_trap {
|
||||
|
||||
struct cpu_user_regs;
|
||||
|
||||
extern void machine_check_vector(struct cpu_user_regs *regs, long error_code);
|
||||
extern void machine_check_vector(const struct cpu_user_regs *regs, long error_code);
|
||||
|
||||
void async_exception_cleanup(struct vcpu *);
|
||||
|
||||
|
||||