x86: Support for CET Indirect Branch Tracking
PATCH 30/65 x86/emul: Annotate fnptr targets
In reply to Andrew Cooperpv_emul_is_mem_write() only has a single user. Having it as a static inline is pointless because it can't be inlined to begin with.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/hvm/emulate.c | 72 +++++++++++++++++----------------- xen/arch/x86/hvm/hvm.c | 8 ++-- xen/arch/x86/hvm/svm/svm.c | 4 +- xen/arch/x86/mm.c | 4 +- xen/arch/x86/mm/shadow/hvm.c | 8 ++-- xen/arch/x86/pv/emul-gate-op.c | 5 ++- xen/arch/x86/pv/emul-priv-op.c | 65 +++++++++++++++--------------- xen/arch/x86/pv/emulate.h | 7 ---- xen/arch/x86/pv/ro-page-fault.c | 25 +++++++----- xen/arch/x86/x86_emulate.c | 21 +++++----- xen/arch/x86/x86_emulate/x86_emulate.c | 10 ++--- xen/arch/x86/x86_emulate/x86_emulate.h | 33 ++++++++-------- xen/include/asm-x86/hvm/emulate.h | 8 ++-- xen/include/asm-x86/mm.h | 16 +++----- 14 files changed, 142 insertions(+), 144 deletions(-)
xen/arch/x86/hvm/emulate.c +36 -36
@@ -1272,7 +1272,7 @@ static int __hvmemul_read(return linear_read (addr, bytes, p_data, pfec, hvmemul_ctxt); } -static int hvmemul_read( +static int cf_check hvmemul_read( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -1290,7 +1290,7 @@ static int hvmemul_read( container_of(ctxt, struct hvm_emulate_ctxt, ctxt)); } -int hvmemul_insn_fetch( +int cf_check hvmemul_insn_fetch( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -1337,7 +1337,7 @@ int hvmemul_insn_fetch(return X86EMUL_OKAY ; } -static int hvmemul_write( +static int cf_check hvmemul_write( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -1385,7 +1385,7 @@ static int hvmemul_write(return X86EMUL_OKAY ; } -static int hvmemul_rmw( +static int cf_check hvmemul_rmw( enum x86_segment seg, unsigned long offset, unsigned int bytes,
@@ -1438,7 +1438,7 @@ static int hvmemul_rmw(return rc; } -static int hvmemul_blk( +static int cf_check hvmemul_blk( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -1479,7 +1479,7 @@ static int hvmemul_blk(return rc; } -static int hvmemul_write_discard( +static int cf_check hvmemul_write_discard( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -1490,7 +1490,7 @@ static int hvmemul_write_discard(return X86EMUL_OKAY ; } -static int hvmemul_rep_ins_discard( +static int cf_check hvmemul_rep_ins_discard( uint16_t src_port, enum x86_segment dst_seg, unsigned long dst_offset,
@@ -1501,7 +1501,7 @@ static int hvmemul_rep_ins_discard(return X86EMUL_OKAY ; } -static int hvmemul_rep_movs_discard( +static int cf_check hvmemul_rep_movs_discard( enum x86_segment src_seg, unsigned long src_offset, enum x86_segment dst_seg,
@@ -1513,7 +1513,7 @@ static int hvmemul_rep_movs_discard(return X86EMUL_OKAY ; } -static int hvmemul_rep_stos_discard( +static int cf_check hvmemul_rep_stos_discard( void *p_data, enum x86_segment seg, unsigned long offset,
@@ -1524,7 +1524,7 @@ static int hvmemul_rep_stos_discard(return X86EMUL_OKAY ; } -static int hvmemul_rep_outs_discard( +static int cf_check hvmemul_rep_outs_discard( enum x86_segment src_seg, unsigned long src_offset, uint16_t dst_port,
@@ -1535,7 +1535,7 @@ static int hvmemul_rep_outs_discard(return X86EMUL_OKAY ; } -static int hvmemul_cmpxchg_discard( +static int cf_check hvmemul_cmpxchg_discard( enum x86_segment seg, unsigned long offset, void *p_old,
@@ -1547,7 +1547,7 @@ static int hvmemul_cmpxchg_discard(return X86EMUL_OKAY ; } -static int hvmemul_read_io_discard( +static int cf_check hvmemul_read_io_discard( unsigned int port, unsigned int bytes, unsigned long *val,
@@ -1556,7 +1556,7 @@ static int hvmemul_read_io_discard(return X86EMUL_OKAY ; } -static int hvmemul_write_io_discard( +static int cf_check hvmemul_write_io_discard( unsigned int port, unsigned int bytes, unsigned long val,
@@ -1565,7 +1565,7 @@ static int hvmemul_write_io_discard(return X86EMUL_OKAY ; } -static int hvmemul_write_msr_discard ( +static int cf_check hvmemul_write_msr_discard(unsigned int reg,uint64_t val,struct x86_emulate_ctxt *ctxt)
@@ -1573,7 +1573,7 @@ static int hvmemul_write_msr_discard(return X86EMUL_OKAY ; } -static int hvmemul_cache_op_discard( +static int cf_check hvmemul_cache_op_discard( enum x86emul_cache_op op, enum x86_segment seg, unsigned long offset,
@@ -1582,7 +1582,7 @@ static int hvmemul_cache_op_discard(return X86EMUL_OKAY ; } -static int hvmemul_cmpxchg( +static int cf_check hvmemul_cmpxchg( enum x86_segment seg, unsigned long offset, void *p_old,
@@ -1676,7 +1676,7 @@ static int hvmemul_cmpxchg(return rc; } -static int hvmemul_validate ( +static int cf_check hvmemul_validate(const struct x86_emulate_state *state,struct x86_emulate_ctxt *ctxt) {
@@ -1689,7 +1689,7 @@ static int hvmemul_validate( ? X86EMUL_OKAY : X86EMUL_UNHANDLEABLE; } -static int hvmemul_rep_ins( +static int cf_check hvmemul_rep_ins( uint16_t src_port, enum x86_segment dst_seg, unsigned long dst_offset,
@@ -1767,7 +1767,7 @@ static int hvmemul_rep_outs_set_context(return rc; } -static int hvmemul_rep_outs( +static int cf_check hvmemul_rep_outs( enum x86_segment src_seg, unsigned long src_offset, uint16_t dst_port,
@@ -1808,7 +1808,7 @@ static int hvmemul_rep_outs( !!(ctxt->regs->eflags & X86_EFLAGS_DF), gpa); } -static int hvmemul_rep_movs( +static int cf_check hvmemul_rep_movs( enum x86_segment src_seg, unsigned long src_offset, enum x86_segment dst_seg,
@@ -1978,7 +1978,7 @@ static int hvmemul_rep_movs(return X86EMUL_UNHANDLEABLE ; } -static int hvmemul_rep_stos( +static int cf_check hvmemul_rep_stos( void *p_data, enum x86_segment seg, unsigned long offset,
@@ -2106,7 +2106,7 @@ static int hvmemul_rep_stos( } } -static int hvmemul_read_segment ( +static int cf_check hvmemul_read_segment(enum x86_segment seg,struct segment_register *reg,struct x86_emulate_ctxt *ctxt)
@@ -2123,7 +2123,7 @@ static int hvmemul_read_segment(return X86EMUL_OKAY ; } -static int hvmemul_write_segment ( +static int cf_check hvmemul_write_segment(enum x86_segment seg,const struct segment_register *reg,struct x86_emulate_ctxt *ctxt)
@@ -2142,7 +2142,7 @@ static int hvmemul_write_segment(return X86EMUL_OKAY ; } -static int hvmemul_read_io( +static int cf_check hvmemul_read_io( unsigned int port, unsigned int bytes, unsigned long *val,
@@ -2159,7 +2159,7 @@ static int hvmemul_read_io(return hvmemul_do_pio_buffer (port, bytes,IOREQ_READ , val); } -static int hvmemul_write_io( +static int cf_check hvmemul_write_io( unsigned int port, unsigned int bytes, unsigned long val,
@@ -2168,7 +2168,7 @@ static int hvmemul_write_io(return hvmemul_do_pio_buffer (port, bytes,IOREQ_WRITE , &val); } -static int hvmemul_read_cr ( +static int cf_check hvmemul_read_cr(unsigned int reg,unsigned long *val,struct x86_emulate_ctxt *ctxt)
@@ -2189,7 +2189,7 @@ static int hvmemul_read_cr(return X86EMUL_UNHANDLEABLE ; } -static int hvmemul_write_cr ( +static int cf_check hvmemul_write_cr(unsigned int reg,unsigned long val,struct x86_emulate_ctxt *ctxt)
@@ -2233,7 +2233,7 @@ static int hvmemul_write_cr(return rc; } -static int hvmemul_read_xcr ( +static int cf_check hvmemul_read_xcr(unsigned int reg,uint64_t *val,struct x86_emulate_ctxt *ctxt)
@@ -2246,7 +2246,7 @@ static int hvmemul_read_xcr(return rc; } -static int hvmemul_write_xcr ( +static int cf_check hvmemul_write_xcr(unsigned int reg,uint64_t val,struct x86_emulate_ctxt *ctxt)
@@ -2256,7 +2256,7 @@ static int hvmemul_write_xcr(return x86emul_write_xcr (reg, val, ctxt); } -static int hvmemul_read_msr ( +static int cf_check hvmemul_read_msr(unsigned int reg,uint64_t *val,struct x86_emulate_ctxt *ctxt)
@@ -2269,7 +2269,7 @@ static int hvmemul_read_msr(return rc; } -static int hvmemul_write_msr ( +static int cf_check hvmemul_write_msr(unsigned int reg,uint64_t val,struct x86_emulate_ctxt *ctxt)
@@ -2282,7 +2282,7 @@ static int hvmemul_write_msr(return rc; } -static int hvmemul_cache_op( +static int cf_check hvmemul_cache_op( enum x86emul_cache_op op, enum x86_segment seg, unsigned long offset,
@@ -2352,7 +2352,7 @@ static int hvmemul_cache_op(return X86EMUL_OKAY ; } -static int hvmemul_get_fpu ( +static int cf_check hvmemul_get_fpu(enum x86_emulate_fpu_type type,struct x86_emulate_ctxt *ctxt) {
@@ -2394,7 +2394,7 @@ static int hvmemul_get_fpu(return X86EMUL_OKAY ; } -static void hvmemul_put_fpu ( +static void cf_check hvmemul_put_fpu(struct x86_emulate_ctxt *ctxt,enum x86_emulate_fpu_type backout,const struct x86_emul_fpu_aux *aux)
@@ -2481,7 +2481,7 @@ static void hvmemul_put_fpu( } } -static int hvmemul_tlb_op( +static int cf_check hvmemul_tlb_op( enum x86emul_tlb_op op, unsigned long addr, unsigned long aux,
@@ -2538,7 +2538,7 @@ static int hvmemul_tlb_op(return rc; } -static int hvmemul_vmfunc ( +static int cf_check hvmemul_vmfunc(struct x86_emulate_ctxt *ctxt) {int rc;
xen/arch/x86/hvm/hvm.c +4 -4
@@ -3737,8 +3737,8 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,return X86EMUL_EXCEPTION ; } -static bool is_sysdesc_access (const struct x86_emulate_state *state, -const struct x86_emulate_ctxt *ctxt) +static bool cf_check is_sysdesc_access( +const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {unsigned int ext;int mode =x86_insn_modrm (state,NULL , &ext);
@@ -3778,8 +3778,8 @@ int hvm_descriptor_access_intercept(uint64_t exit_info,return X86EMUL_OKAY ; } -static bool is_cross_vendor (const struct x86_emulate_state *state, -const struct x86_emulate_ctxt *ctxt) +static bool cf_check is_cross_vendor( +const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {switch ( ctxt->opcode ) {
xen/arch/x86/hvm/svm/svm.c +2 -2
@@ -2443,8 +2443,8 @@ static void svm_invlpg_intercept(unsigned long linear)paging_invlpg (current, linear); } -static bool is_invlpg (const struct x86_emulate_state *state, -const struct x86_emulate_ctxt *ctxt) +static bool cf_check is_invlpg( +const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {unsigned int ext;
xen/arch/x86/mm.c +2 -2
@@ -4838,7 +4838,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)return 0 ; } -int mmio_ro_emulated_write( +int cf_check mmio_ro_emulated_write( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -4859,7 +4859,7 @@ int mmio_ro_emulated_write(return X86EMUL_OKAY ; } -int mmcfg_intercept_write( +int cf_check mmcfg_intercept_write( enum x86_segment seg, unsigned long offset, void *p_data,
xen/arch/x86/mm/shadow/hvm.c +4 -4
@@ -148,7 +148,7 @@ hvm_read(enum x86_segment seg,return X86EMUL_UNHANDLEABLE ; } -static int +static int cf_check hvm_emulate_read(enum x86_segment seg, unsigned long offset, void *p_data,
@@ -161,7 +161,7 @@ hvm_emulate_read(enum x86_segment seg, container_of(ctxt, struct sh_emulate_ctxt, ctxt)); } -static int +static int cf_check hvm_emulate_insn_fetch(enum x86_segment seg, unsigned long offset, void *p_data,
@@ -184,7 +184,7 @@ hvm_emulate_insn_fetch(enum x86_segment seg,return X86EMUL_OKAY ; } -static int +static int cf_check hvm_emulate_write(enum x86_segment seg, unsigned long offset, void *p_data,
@@ -237,7 +237,7 @@ hvm_emulate_write(enum x86_segment seg,return X86EMUL_OKAY ; } -static int +static int cf_check hvm_emulate_cmpxchg(enum x86_segment seg, unsigned long offset, void *p_old,
xen/arch/x86/pv/emul-gate-op.c +3 -2
@@ -96,8 +96,9 @@ struct gate_op_ctxt {bool insn_fetch; }; -static int read_mem (enum x86_segment seg,unsigned long offset,void *p_data, -unsigned int bytes,struct x86_emulate_ctxt *ctxt) +static int cf_check read_mem( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt) {const struct gate_op_ctxt *goc = container_of(ctxt, struct gate_op_ctxt, ctxt);
xen/arch/x86/pv/emul-priv-op.c +33 -32
137 lines not on this page · raw message
xen/arch/x86/pv/emulate.h +0 -7
@@ -12,13 +12,6 @@ int pv_emul_read_descriptor(unsigned int sel, const struct vcpu *v,void pv_emul_instruction_done (struct cpu_user_regs *regs,unsigned long rip); -static inline int pv_emul_is_mem_write (const struct x86_emulate_state *state, -struct x86_emulate_ctxt *ctxt) -{ -return x86_insn_is_mem_write (state, ctxt) ?X86EMUL_OKAY - :X86EMUL_UNHANDLEABLE ; -} -/* Return a pointer to the GDT/LDT descriptor referenced by sel. */ static inline const seg_desc_t *gdt_ldt_desc_ptr (unsigned int sel) {
xen/arch/x86/pv/ro-page-fault.c +16 -9
@@ -26,6 +26,13 @@#include "emulate.h" #include "mm.h" +static int cf_check pv_emul_is_mem_write( +const struct x86_emulate_state *state,struct x86_emulate_ctxt *ctxt) +{ +return x86_insn_is_mem_write (state, ctxt) ?X86EMUL_OKAY + :X86EMUL_UNHANDLEABLE ; +} +/********************* * Writable Pagetables */
@@ -35,9 +42,9 @@ struct ptwr_emulate_ctxt {l1_pgentry_t pte; }; -static int ptwr_emulated_read (enum x86_segment seg,unsigned long offset, -void *p_data,unsigned int bytes, -struct x86_emulate_ctxt *ctxt) +static int cf_check ptwr_emulated_read( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt) {unsigned int rc = bytes;unsigned long addr = offset;
@@ -203,9 +210,9 @@ static int ptwr_emulated_update(unsigned long addr, intpte_t *p_old,return X86EMUL_OKAY ; } -static int ptwr_emulated_write (enum x86_segment seg,unsigned long offset, -void *p_data,unsigned int bytes, -struct x86_emulate_ctxt *ctxt) +static int cf_check ptwr_emulated_write( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt) {intpte_t val =0 ;
@@ -221,9 +228,9 @@ static int ptwr_emulated_write(enum x86_segment seg, unsigned long offset,return ptwr_emulated_update (offset,NULL , val, bytes, ctxt); } -static int ptwr_emulated_cmpxchg (enum x86_segment seg,unsigned long offset, -void *p_old,void *p_new,unsigned int bytes, -bool lock,struct x86_emulate_ctxt *ctxt) +static int cf_check ptwr_emulated_cmpxchg( +enum x86_segment seg,unsigned long offset,void *p_old,void *p_new, +unsigned int bytes,bool lock,struct x86_emulate_ctxt *ctxt) {intpte_t old =0 , new =0 ;int rc;
xen/arch/x86/x86_emulate.c +11 -10
@@ -53,8 +53,8 @@#include "x86_emulate/x86_emulate.c" -int x86emul_read_xcr (unsigned int reg,uint64_t *val, -struct x86_emulate_ctxt *ctxt) +int cf_check x86emul_read_xcr( +unsigned int reg,uint64_t *val,struct x86_emulate_ctxt *ctxt) {switch ( reg ) {
@@ -77,8 +77,8 @@ int x86emul_read_xcr(unsigned int reg, uint64_t *val, }/* Note: May be called with ctxt=NULL. */ -int x86emul_write_xcr (unsigned int reg,uint64_t val, -struct x86_emulate_ctxt *ctxt) +int cf_check x86emul_write_xcr( +unsigned int reg,uint64_t val,struct x86_emulate_ctxt *ctxt) {switch ( reg ) {
@@ -100,8 +100,8 @@ int x86emul_write_xcr(unsigned int reg, uint64_t val,#ifdef CONFIG_PV /* Called with NULL ctxt in hypercall context. */ -int x86emul_read_dr (unsigned int reg,unsigned long *val, -struct x86_emulate_ctxt *ctxt) +int cf_check x86emul_read_dr( +unsigned int reg,unsigned long *val,struct x86_emulate_ctxt *ctxt) {struct vcpu *curr = current;
@@ -143,8 +143,8 @@ int x86emul_read_dr(unsigned int reg, unsigned long *val,return X86EMUL_OKAY ; } -int x86emul_write_dr (unsigned int reg,unsigned long val, -struct x86_emulate_ctxt *ctxt) +int cf_check x86emul_write_dr( +unsigned int reg,unsigned long val,struct x86_emulate_ctxt *ctxt) {struct vcpu *curr = current;
@@ -167,8 +167,9 @@ int x86emul_write_dr(unsigned int reg, unsigned long val, }#endif /* CONFIG_PV */ -int x86emul_cpuid (uint32_t leaf,uint32_t subleaf, -struct cpuid_leaf *res,struct x86_emulate_ctxt *ctxt) +int cf_check x86emul_cpuid( +uint32_t leaf,uint32_t subleaf,struct cpuid_leaf *res, +struct x86_emulate_ctxt *ctxt) {guest_cpuid (current, leaf, subleaf, res);
xen/arch/x86/x86_emulate/x86_emulate.c +5 -5
@@ -2524,7 +2524,7 @@ static void adjust_bnd(struct x86_emulate_ctxt *ctxt, done:; } -int x86emul_unhandleable_rw( +int cf_check x86emul_unhandleable_rw( enum x86_segment seg, unsigned long offset, void *p_data,
@@ -12319,7 +12319,7 @@ x86_insn_operand_ea(const struct x86_emulate_state *state,* memory operand (like POP), but it does not mean e.g. segment selector * loads, where the descriptor table access is considered an implicit one. */ -bool +bool cf_checkx86_insn_is_mem_access (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {
@@ -12411,7 +12411,7 @@ x86_insn_is_mem_access(const struct x86_emulate_state *state,* loads, where the (possible) descriptor table write is considered an * implicit access. */ -bool +bool cf_checkx86_insn_is_mem_write (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {
@@ -12583,7 +12583,7 @@ x86_insn_is_mem_write(const struct x86_emulate_state *state,return false; } -bool +bool cf_checkx86_insn_is_portio (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {
@@ -12598,7 +12598,7 @@ x86_insn_is_portio(const struct x86_emulate_state *state,return false; } -bool +bool cf_checkx86_insn_is_cr_access (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt) {
xen/arch/x86/x86_emulate/x86_emulate.h +17 -16
@@ -743,7 +743,7 @@ static inline unsigned long *decode_gpr(struct cpu_user_regs *regs, }/* Unhandleable read, write or instruction fetch */ -int +int cf_check x86emul_unhandleable_rw( enum x86_segment seg, unsigned long offset,
@@ -773,16 +773,16 @@ x86_insn_immediate(const struct x86_emulate_state *state,unsigned int x86_insn_length (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt); -bool +bool cf_checkx86_insn_is_mem_access (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt); -bool +bool cf_checkx86_insn_is_mem_write (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt); -bool +bool cf_checkx86_insn_is_portio (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt); -bool +bool cf_checkx86_insn_is_cr_access (const struct x86_emulate_state *state,const struct x86_emulate_ctxt *ctxt);
@@ -794,17 +794,18 @@ void x86_emulate_free_state(struct x86_emulate_state *state);#ifdef __XEN__ -int x86emul_read_xcr (unsigned int reg,uint64_t *val, -struct x86_emulate_ctxt *ctxt); -int x86emul_write_xcr (unsigned int reg,uint64_t val, -struct x86_emulate_ctxt *ctxt); - -int x86emul_read_dr (unsigned int reg,unsigned long *val, -struct x86_emulate_ctxt *ctxt); -int x86emul_write_dr (unsigned int reg,unsigned long val, -struct x86_emulate_ctxt *ctxt); -int x86emul_cpuid (uint32_t leaf,uint32_t subleaf, -struct cpuid_leaf *res,struct x86_emulate_ctxt *ctxt); +int cf_check x86emul_read_xcr( +unsigned int reg,uint64_t *val,struct x86_emulate_ctxt *ctxt); +int cf_check x86emul_write_xcr( +unsigned int reg,uint64_t val,struct x86_emulate_ctxt *ctxt); + +int cf_check x86emul_read_dr( +unsigned int reg,unsigned long *val,struct x86_emulate_ctxt *ctxt); +int cf_check x86emul_write_dr( +unsigned int reg,unsigned long val,struct x86_emulate_ctxt *ctxt); +int cf_check x86emul_cpuid( +uint32_t leaf,uint32_t subleaf,struct cpuid_leaf *res, +struct x86_emulate_ctxt *ctxt);#endif
xen/include/asm-x86/hvm/emulate.h +3 -5
@@ -92,11 +92,9 @@ static inline bool handle_mmio(void)return hvm_emulate_one_insn (x86_insn_is_mem_access,"MMIO" ); } -int hvmemul_insn_fetch (enum x86_segment seg, -unsigned long offset, -void *p_data, -unsigned int bytes, -struct x86_emulate_ctxt *ctxt); +int cf_check hvmemul_insn_fetch( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt); int hvmemul_do_pio_buffer(uint16_t port, unsigned int size, uint8_t dir,
xen/include/asm-x86/mm.h +6 -10
@@ -546,16 +546,12 @@ struct mmio_ro_emulate_ctxt {unsigned int seg, bdf; }; -extern int mmio_ro_emulated_write (enum x86_segment seg, -unsigned long offset, -void *p_data, -unsigned int bytes, -struct x86_emulate_ctxt *ctxt); -extern int mmcfg_intercept_write (enum x86_segment seg, -unsigned long offset, -void *p_data, -unsigned int bytes, -struct x86_emulate_ctxt *ctxt); +int cf_check mmio_ro_emulated_write( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt); +int cf_check mmcfg_intercept_write( +enum x86_segment seg,unsigned long offset,void *p_data, +unsigned int bytes,struct x86_emulate_ctxt *ctxt);int audit_adjust_pgtables (struct domain *d,int dir,int noisy);
Signature · 1 line
2.11.0
Re: [PATCH 30/65] x86/emul: Annotate fnptr targets
Quoted 1 line · Andrew Cooper
pv_emul_is_mem_write()only has a single user.
Aiui you mean a single file using it; there I can spot three uses.
Quoted 2 lines
Having it as a static inline
is pointless because it can't be inlined to begin with.
As long as it's only used to set function pointer fields, yes.
Jan
PATCH 31/65 x86/ucode: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/microcode/amd.c | 9 +++++---- xen/arch/x86/cpu/microcode/core.c | 4 ++-- xen/arch/x86/cpu/microcode/intel.c | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-)
xen/arch/x86/cpu/microcode/amd.c +5 -4
@@ -91,7 +91,7 @@ static struct {uint16_t id; } equiv__read_mostly ; -static void collect_cpu_info (void ) +static void cf_check collect_cpu_info(void) {struct cpu_signature *csig = &this_cpu (cpu_sig);
@@ -204,7 +204,7 @@ static enum microcode_match_result compare_header(return compare_revisions (old->patch_id, new->patch_id); } -static enum microcode_match_result compare_patch ( +static enum microcode_match_result cf_check compare_patch(const struct microcode_patch *new,const struct microcode_patch *old) {/* Both patches to compare are supposed to be applicable to local CPU. */
@@ -214,7 +214,7 @@ static enum microcode_match_result compare_patch(return compare_header (new, old); } -static int apply_microcode (const struct microcode_patch *patch) +static int cf_check apply_microcode(const struct microcode_patch *patch) {int hw_err;unsigned int cpu =smp_processor_id ();
@@ -299,7 +299,8 @@ static int scan_equiv_cpu_table(const struct container_equiv_table *et)return -ESRCH ; } -static struct microcode_patch *cpu_request_microcode (const void *buf,size_t size) +static struct microcode_patch *cf_check cpu_request_microcode( +const void *buf,size_t size) {const struct microcode_patch *saved =NULL ;struct microcode_patch *patch =NULL ;
xen/arch/x86/cpu/microcode/core.c +2 -2
@@ -291,12 +291,12 @@ static int wait_for_condition(bool (*func)(unsigned int data),return 0 ; } -static bool wait_cpu_callin (unsigned int nr) +static bool cf_check wait_cpu_callin(unsigned int nr) {return cpumask_weight (&cpu_callin_map) >= nr; } -static bool wait_cpu_callout (unsigned int nr) +static bool cf_check wait_cpu_callout(unsigned int nr) {return atomic_read (&cpu_out) >= nr; }
xen/arch/x86/cpu/microcode/intel.c +5 -5
@@ -116,7 +116,7 @@ static bool signature_matches(const struct cpu_signature *cpu_sig,return cpu_sig->pf & ucode_pf; } -static void collect_cpu_info (void ) +static void cf_check collect_cpu_info(void) {struct cpu_signature *csig = &this_cpu (cpu_sig);uint64_t msr_content;
@@ -271,7 +271,7 @@ static enum microcode_match_result microcode_update_match(return compare_revisions (cpu_sig->rev, mc->rev); } -static enum microcode_match_result compare_patch ( +static enum microcode_match_result cf_check compare_patch(const struct microcode_patch *new,const struct microcode_patch *old) {/*
@@ -284,7 +284,7 @@ static enum microcode_match_result compare_patch(return compare_revisions (old->rev, new->rev); } -static int apply_microcode (const struct microcode_patch *patch) +static int cf_check apply_microcode(const struct microcode_patch *patch) {uint64_t msr_content;unsigned int cpu =smp_processor_id ();
@@ -323,8 +323,8 @@ static int apply_microcode(const struct microcode_patch *patch)return 0 ; } -static struct microcode_patch *cpu_request_microcode (const void *buf, -size_t size) +static struct microcode_patch *cf_check cpu_request_microcode( +const void *buf,size_t size) {int error =0 ;const struct microcode_patch *saved =NULL ;
Signature · 1 line
2.11.0
PATCH 32/65 x86/power: Annotate fnptr targets
In reply to Andrew Coopercpufreq_governor_dbs() has no external callers so make it static.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/acpi/cpufreq/cpufreq.c | 14 +++++++------- xen/arch/x86/acpi/cpufreq/powernow.c | 15 ++++++++------- xen/common/core_parking.c | 4 ++-- xen/drivers/cpufreq/cpufreq_ondemand.c | 6 ++++-- xen/include/acpi/cpufreq/cpufreq.h | 1 - 5 files changed, 21 insertions(+), 19 deletions(-)
xen/arch/x86/acpi/cpufreq/cpufreq.c +7 -7
@@ -320,7 +320,7 @@ unsigned int get_measured_perf(unsigned int cpu, unsigned int flag)return policy->cpuinfo.max_freq * perf_percent /100 ; } -static unsigned int get_cur_freq_on_cpu (unsigned int cpu) +static unsigned int cf_check get_cur_freq_on_cpu(unsigned int cpu) {struct cpufreq_policy *policy;struct acpi_cpufreq_data *data;
@@ -369,8 +369,9 @@ static unsigned int check_freqs(const cpumask_t *mask, unsigned int freq,return 0 ; } -static int acpi_cpufreq_target (struct cpufreq_policy *policy, -unsigned int target_freq,unsigned int relation) +static int cf_check acpi_cpufreq_target( +struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) {struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];struct processor_performance *perf;
@@ -449,7 +450,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,return result; } -static int acpi_cpufreq_verify (struct cpufreq_policy *policy) +static int cf_check acpi_cpufreq_verify(struct cpufreq_policy *policy) {struct acpi_cpufreq_data *data;struct processor_performance *perf;
@@ -494,8 +495,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) } } -static int -acpi_cpufreq_cpu_init (struct cpufreq_policy *policy) +static int cf_check acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) {unsigned int i;unsigned int valid_states =0 ;
@@ -609,7 +609,7 @@ acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)return result; } -static int acpi_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static int cf_check acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) {struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
xen/arch/x86/acpi/cpufreq/powernow.c +8 -7
@@ -67,8 +67,8 @@ static void cf_check update_cpb(void *data) } } -static int powernow_cpufreq_update (int cpuid, -struct cpufreq_policy *policy) +static int cf_check powernow_cpufreq_update( +int cpuid,struct cpufreq_policy *policy) {if (!cpumask_test_cpu (cpuid, &cpu_online_map))return -EINVAL ;
@@ -78,8 +78,9 @@ static int powernow_cpufreq_update (int cpuid,return 0 ; } -static int powernow_cpufreq_target (struct cpufreq_policy *policy, -unsigned int target_freq,unsigned int relation) +static int cf_check powernow_cpufreq_target( +struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) {struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];struct processor_performance *perf;
@@ -180,7 +181,7 @@ static void cf_check get_cpu_data(void *arg)amd_fixup_frequency (&perf->states[i]); } -static int powernow_cpufreq_verify (struct cpufreq_policy *policy) +static int cf_check powernow_cpufreq_verify(struct cpufreq_policy *policy) {struct acpi_cpufreq_data *data;struct processor_performance *perf;
@@ -197,7 +198,7 @@ static int powernow_cpufreq_verify(struct cpufreq_policy *policy)return cpufreq_frequency_table_verify (policy, data->freq_table); } -static int powernow_cpufreq_cpu_init (struct cpufreq_policy *policy) +static int cf_check powernow_cpufreq_cpu_init(struct cpufreq_policy *policy) {unsigned int i;unsigned int valid_states =0 ;
@@ -303,7 +304,7 @@ static int powernow_cpufreq_cpu_init(struct cpufreq_policy *policy)return result; } -static int powernow_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static int cf_check powernow_cpufreq_cpu_exit(struct cpufreq_policy *policy) {struct acpi_cpufreq_data *data = cpufreq_drv_data[policy->cpu];
xen/common/core_parking.c +2 -2
@@ -53,7 +53,7 @@ static int __init cf_check setup_core_parking_option(const char *str) }custom_param ("core_parking" , setup_core_parking_option); -static unsigned int core_parking_performance (unsigned int event) +static unsigned int cf_check core_parking_performance(unsigned int event) {unsigned int cpu =-1 ;
@@ -111,7 +111,7 @@ static unsigned int core_parking_performance(unsigned int event)return cpu; } -static unsigned int core_parking_power (unsigned int event) +static unsigned int cf_check core_parking_power(unsigned int event) {unsigned int cpu =-1 ;
xen/drivers/cpufreq/cpufreq_ondemand.c +4 -2
@@ -215,7 +215,8 @@ static void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)kill_timer (&per_cpu (dbs_timer, dbs_info->cpu)); } -int cpufreq_governor_dbs (struct cpufreq_policy *policy,unsigned int event) +static int cf_check cpufreq_governor_dbs( +struct cpufreq_policy *policy,unsigned int event) {unsigned int cpu = policy->cpu;struct cpu_dbs_info_s *this_dbs_info;
@@ -307,7 +308,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)return 0 ; } -static bool_t __init cpufreq_dbs_handle_option (const char *name,const char *val) +static bool __init cf_check cpufreq_dbs_handle_option( +const char *name,const char *val) {if ( !strcmp (name,"rate" ) && val ) {
xen/include/acpi/cpufreq/cpufreq.h +0 -1
@@ -227,7 +227,6 @@ struct cpu_dbs_info_s {int8_t stoppable; }; -int cpufreq_governor_dbs (struct cpufreq_policy *policy,unsigned int event); int get_cpufreq_ondemand_para(uint32_t *sampling_rate_max, uint32_t *sampling_rate_min, uint32_t *sampling_rate,
Signature · 1 line
2.11.0
PATCH 33/65 x86/apic: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/genapic/bigsmp.c | 4 ++-- xen/arch/x86/genapic/delivery.c | 12 ++++++------ xen/arch/x86/genapic/x2apic.c | 16 ++++++++++------ xen/arch/x86/smp.c | 6 +++--- xen/include/asm-x86/genapic.h | 18 +++++++++--------- 5 files changed, 30 insertions(+), 26 deletions(-)
xen/arch/x86/genapic/bigsmp.c +2 -2
@@ -10,7 +10,7 @@#include <xen/dmi.h> #include <asm/io_apic.h> -static __init int force_bigsmp (const struct dmi_system_id *d) +static int __init cf_check force_bigsmp(const struct dmi_system_id *d) {printk (KERN_NOTICE "%s detected: force use of apic=bigsmp\n" , d->ident); def_to_bigsmp = true;
@@ -27,7 +27,7 @@ static const struct dmi_system_id __initconstrel bigsmp_dmi_table[] = { }; -static __init int probe_bigsmp (void ) +static int __init cf_check probe_bigsmp(void) {/* * We don't implement cluster mode, so force use of
xen/arch/x86/genapic/delivery.c +6 -6
@@ -9,7 +9,7 @@* LOGICAL FLAT DELIVERY MODE (multicast via bitmask to <= 8 logical APIC IDs). */ -void init_apic_ldr_flat (void ) +void cf_check init_apic_ldr_flat(void) {unsigned long val;
@@ -19,12 +19,12 @@ void init_apic_ldr_flat(void)apic_write (APIC_LDR , val); } -const cpumask_t *vector_allocation_cpumask_flat (int cpu) +const cpumask_t *cf_check vector_allocation_cpumask_flat(int cpu) {return &cpu_online_map; } -unsigned int cpu_mask_to_apicid_flat (const cpumask_t *cpumask) +unsigned int cf_check cpu_mask_to_apicid_flat(const cpumask_t *cpumask) {return cpumask_bits (cpumask)[0 ]&0xFF ; }
@@ -33,17 +33,17 @@ unsigned int cpu_mask_to_apicid_flat(const cpumask_t *cpumask)* PHYSICAL DELIVERY MODE (unicast to physical APIC IDs). */ -void init_apic_ldr_phys (void ) +void cf_check init_apic_ldr_phys(void) {/* We only deliver in phys mode - no setup needed. */ } -const cpumask_t *vector_allocation_cpumask_phys (int cpu) +const cpumask_t *cf_check vector_allocation_cpumask_phys(int cpu) {return cpumask_of (cpu); } -unsigned int cpu_mask_to_apicid_phys (const cpumask_t *cpumask) +unsigned int cf_check cpu_mask_to_apicid_phys(const cpumask_t *cpumask) {/* As we are using single CPU as destination, pick only one CPU here */ return cpu_physical_id (cpumask_any (cpumask));
xen/arch/x86/genapic/x2apic.c +10 -6
@@ -38,7 +38,7 @@ static inline u32 x2apic_cluster(unsigned int cpu)return per_cpu (cpu_2_logical_apicid, cpu) >>16 ; } -static void init_apic_ldr_x2apic_cluster (void ) +static void cf_check init_apic_ldr_x2apic_cluster(void) {unsigned int cpu, this_cpu =smp_processor_id ();
@@ -74,12 +74,14 @@ static void init_apic_ldr_x2apic_cluster(void)cpumask_set_cpu (this_cpu,per_cpu (cluster_cpus, this_cpu)); } -static const cpumask_t *vector_allocation_cpumask_x2apic_cluster (int cpu) +static const cpumask_t *cf_check vector_allocation_cpumask_x2apic_cluster( +int cpu) {return per_cpu (cluster_cpus, cpu); } -static unsigned int cpu_mask_to_apicid_x2apic_cluster (const cpumask_t *cpumask) +static unsigned int cf_check cpu_mask_to_apicid_x2apic_cluster( +const cpumask_t *cpumask) {unsigned int cpu =cpumask_any (cpumask);unsigned int dest =per_cpu (cpu_2_logical_apicid, cpu);
@@ -92,12 +94,13 @@ static unsigned int cpu_mask_to_apicid_x2apic_cluster(const cpumask_t *cpumask)return dest; } -static void send_IPI_self_x2apic (uint8_t vector) +static void cf_check send_IPI_self_x2apic(uint8_t vector) {apic_wrmsr (APIC_SELF_IPI , vector); } -static void send_IPI_mask_x2apic_phys (const cpumask_t *cpumask,int vector) +static void cf_check send_IPI_mask_x2apic_phys( +const cpumask_t *cpumask,int vector) {unsigned int cpu;unsigned long flags;
@@ -130,7 +133,8 @@ static void send_IPI_mask_x2apic_phys(const cpumask_t *cpumask, int vector)local_irq_restore (flags); } -static void send_IPI_mask_x2apic_cluster (const cpumask_t *cpumask,int vector) +static void cf_check send_IPI_mask_x2apic_cluster( +const cpumask_t *cpumask,int vector) {unsigned int cpu =smp_processor_id ();cpumask_t *ipimask =per_cpu (scratch_mask, cpu);
xen/arch/x86/smp.c +3 -3
@@ -161,13 +161,13 @@ void send_IPI_self(int vector)* The following functions deal with sending IPIs between CPUs. */ -void send_IPI_self_legacy (uint8_t vector) +void cf_check send_IPI_self_legacy(uint8_t vector) {/* NMI continuation handling relies on using a shorthand here. */ send_IPI_shortcut (APIC_DEST_SELF , vector,APIC_DEST_PHYSICAL ); } -void send_IPI_mask_flat (const cpumask_t *cpumask,int vector) +void cf_check send_IPI_mask_flat(const cpumask_t *cpumask, int vector) {unsigned long mask =cpumask_bits (cpumask)[0 ];unsigned long cfg;
@@ -204,7 +204,7 @@ void send_IPI_mask_flat(const cpumask_t *cpumask, int vector)local_irq_restore (flags); } -void send_IPI_mask_phys (const cpumask_t *mask,int vector) +void cf_check send_IPI_mask_phys(const cpumask_t *mask, int vector) {unsigned long cfg, flags;unsigned int query_cpu;
xen/include/asm-x86/genapic.h +9 -9
@@ -39,12 +39,12 @@ extern struct genapic genapic;extern const struct genapic apic_default;extern const struct genapic apic_bigsmp; -void send_IPI_self_legacy (uint8_t vector); +void cf_check send_IPI_self_legacy(uint8_t vector); -void init_apic_ldr_flat (void ); -unsigned int cpu_mask_to_apicid_flat (const cpumask_t *cpumask); -void send_IPI_mask_flat (const cpumask_t *mask,int vector); -const cpumask_t *vector_allocation_cpumask_flat (int cpu); +void cf_check init_apic_ldr_flat(void); +unsigned int cf_check cpu_mask_to_apicid_flat(const cpumask_t *cpumask); +void cf_check send_IPI_mask_flat(const cpumask_t *mask, int vector); +const cpumask_t *cf_check vector_allocation_cpumask_flat(int cpu); #define GENAPIC_FLAT \ .int_delivery_mode = dest_LowestPrio, \ .int_dest_mode = 1 /* logical delivery */, \
@@ -54,10 +54,10 @@ const cpumask_t *vector_allocation_cpumask_flat(int cpu); .send_IPI_mask = send_IPI_mask_flat, \ .send_IPI_self = send_IPI_self_legacy -void init_apic_ldr_phys (void ); -unsigned int cpu_mask_to_apicid_phys (const cpumask_t *cpumask); -void send_IPI_mask_phys (const cpumask_t *mask,int vector); -const cpumask_t *vector_allocation_cpumask_phys (int cpu); +void cf_check init_apic_ldr_phys(void); +unsigned int cf_check cpu_mask_to_apicid_phys(const cpumask_t *cpumask); +void cf_check send_IPI_mask_phys(const cpumask_t *mask, int vector); +const cpumask_t *cf_check vector_allocation_cpumask_phys(int cpu); #define GENAPIC_PHYS \ .int_delivery_mode = dest_Fixed, \ .int_dest_mode = 0 /* physical delivery */, \
Signature · 1 line
2.11.0
PATCH 34/65 x86/nmi: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/alternative.c | 4 ++-- xen/arch/x86/cpu/microcode/core.c | 3 ++- xen/arch/x86/crash.c | 3 ++- xen/arch/x86/livepatch.c | 2 +- xen/arch/x86/oprofile/nmi_int.c | 2 +- xen/arch/x86/traps.c | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-)
xen/arch/x86/alternative.c +2 -2
@@ -324,8 +324,8 @@ static unsigned int __initdata alt_done;* condition where an NMI hits while we are midway though patching some * instructions in the NMI path. */ -static int __init nmi_apply_alternatives (const struct cpu_user_regs *regs, -int cpu) +static int __init cf_check nmi_apply_alternatives( +const struct cpu_user_regs *regs,int cpu) {/* * More than one NMI may occur between the two set_nmi_callback() below.
xen/arch/x86/cpu/microcode/core.c +2 -1
@@ -376,7 +376,8 @@ static int primary_thread_work(const struct microcode_patch *patch)return ret; } -static int microcode_nmi_callback (const struct cpu_user_regs *regs,int cpu) +static int cf_check microcode_nmi_callback( +const struct cpu_user_regs *regs,int cpu) {unsigned int primary =cpumask_first (this_cpu (cpu_sibling_mask));int ret;
xen/arch/x86/crash.c +2 -1
@@ -36,7 +36,8 @@ static unsigned int crashing_cpu; static DEFINE_PER_CPU_READ_MOSTLY(bool, crash_save_done);/* This becomes the NMI handler for non-crashing CPUs, when Xen is crashing. */ -static int noreturndo_nmi_crash (const struct cpu_user_regs *regs,int cpu) +static int noreturn cf_check do_nmi_crash( +const struct cpu_user_regs *regs,int cpu) {stac ();
xen/arch/x86/livepatch.c +1 -1
@@ -174,7 +174,7 @@ static nmi_callback_t *saved_nmi_callback;* Note that because of this NOP code the do_nmi is not safely patchable. * Also if we do receive 'real' NMIs we have lost them. */ -static int mask_nmi_callback (const struct cpu_user_regs *regs,int cpu) +static int cf_check mask_nmi_callback(const struct cpu_user_regs *regs, int cpu) {/* TODO: Handle missing NMI/MCE.*/ return 1 ;
xen/arch/x86/oprofile/nmi_int.c +1 -1
@@ -95,7 +95,7 @@ bool nmi_oprofile_send_virq(void)return v; } -static int nmi_callback (const struct cpu_user_regs *regs,int cpu) +static int cf_check nmi_callback(const struct cpu_user_regs *regs, int cpu) {int xen_mode, ovf;
xen/arch/x86/traps.c +2 -1
@@ -741,7 +741,8 @@ static cpumask_t show_state_mask;static bool opt_show_all;boolean_param ("async-show-all" , opt_show_all); -static int nmi_show_execution_state (const struct cpu_user_regs *regs,int cpu) +static int cf_check nmi_show_execution_state( +const struct cpu_user_regs *regs,int cpu) {if ( !cpumask_test_cpu (cpu, &show_state_mask) )return 0 ;
Signature · 1 line
2.11.0
PATCH 35/65 x86/mtrr: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
Most of mtrr/ looks to be compatibility for pre-64bit days. It can probably be pruned substantially.
--- xen/arch/x86/cpu/mtrr/generic.c | 18 ++++++++++-------- xen/arch/x86/cpu/mtrr/mtrr.h | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-)
xen/arch/x86/cpu/mtrr/generic.c +10 -8
@@ -287,7 +287,8 @@ static void set_fixed_range(int msr, bool *changed, unsigned int *msrwords) } } -int generic_get_free_region (unsigned long base,unsigned long size,int replace_reg) +int cf_check generic_get_free_region( +unsigned long base,unsigned long size,int replace_reg)/* [SUMMARY] Get a free MTRR. <base> The starting (base) address of the region. <size> The size (in bytes) of the region.
@@ -309,8 +310,8 @@ int generic_get_free_region(unsigned long base, unsigned long size, int replace_return -ENOSPC ; } -static void generic_get_mtrr (unsigned int reg,unsigned long *base, -unsigned long *size,mtrr_type *type) +static void cf_check generic_get_mtrr( +unsigned int reg,unsigned long *base,unsigned long *size,mtrr_type *type) {uint64_t _mask, _base;
@@ -499,7 +500,7 @@ static void post_set(bool pge)spin_unlock (&set_atomicity_lock); } -static void generic_set_all (void ) +static void cf_check generic_set_all(void) {unsigned long mask, count;unsigned long flags;
@@ -522,8 +523,8 @@ static void generic_set_all(void) } } -static void generic_set_mtrr (unsigned int reg,unsigned long base, -unsigned long size,mtrr_type type) +static void cf_check generic_set_mtrr( +unsigned int reg,unsigned long base,unsigned long size,mtrr_type type)/* [SUMMARY] Set variable MTRR register on the local CPU. <reg> The register to set. <base> The base address of the region.
@@ -566,7 +567,8 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base,local_irq_restore (flags); } -int generic_validate_add_page (unsigned long base,unsigned long size,unsigned int type) +int cf_check generic_validate_add_page( +unsigned long base,unsigned long size,unsigned int type) {unsigned long lbase, last;
@@ -584,7 +586,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i } -static int generic_have_wrcomb (void ) +static int cf_check generic_have_wrcomb(void) {unsigned long config;rdmsrl (MSR_MTRRcap, config);
xen/arch/x86/cpu/mtrr/mtrr.h +4 -4
@@ -24,10 +24,10 @@ struct mtrr_ops {int (*have_wrcomb)(void ); }; -extern int generic_get_free_region (unsigned long base,unsigned long size, -int replace_reg); -extern int generic_validate_add_page (unsigned long base,unsigned long size, -unsigned int type); +int cf_check generic_get_free_region( +unsigned long base,unsigned long size,int replace_reg); +int cf_check generic_validate_add_page( +unsigned long base,unsigned long size,unsigned int type);extern const struct mtrr_ops generic_mtrr_ops;
Signature · 1 line
2.11.0
PATCH 36/65 x86/idle: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/acpi/cpu_idle.c | 31 +++++++++++++++++++++------- xen/arch/x86/acpi/cpuidle_menu.c | 6 +++--- xen/arch/x86/cpu/mwait-idle.c | 2 +- xen/arch/x86/domain.c | 6 +++--- xen/arch/x86/hpet.c | 4 ++-- xen/arch/x86/time.c | 6 +++--- xen/drivers/cpufreq/cpufreq_misc_governors.c | 14 ++++++------- xen/include/asm-x86/cpuidle.h | 4 ++-- xen/include/asm-x86/hpet.h | 4 ++-- xen/include/asm-x86/time.h | 6 +++--- 10 files changed, 49 insertions(+), 34 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +23 -8
@@ -75,7 +75,7 @@#define GET_CC7_RES (val) GET_HW_RES_IN_NS(0x3FE, val)/* SNB onwards */ #define PHI_CC6_RES (val) GET_HW_RES_IN_NS(0x3FF, val)/* Xeon Phi only */ -static void lapic_timer_nop (void ) { } +static void cf_check lapic_timer_nop(void) { }void (*__read_mostly lapic_timer_off)(void );void (*__read_mostly lapic_timer_on)(void );
@@ -310,12 +310,27 @@ static char* acpi_cstate_method_name[] ="HALT" }; -static uint64_t get_stime_tick (void ) {return (uint64_t )NOW (); } -static uint64_t stime_ticks_elapsed (uint64_t t1,uint64_t t2) {return t2 - t1; } -static uint64_t stime_tick_to_ns (uint64_t ticks) {return ticks; } +static uint64_t cf_check get_stime_tick(void) +{ +return NOW (); +} + +static uint64_t cf_check stime_ticks_elapsed(uint64_t t1, uint64_t t2) +{ +return t2 - t1; +} + +static uint64_t cf_check stime_tick_to_ns(uint64_t ticks) +{ +return ticks; +} + +static uint64_t cf_check get_acpi_pm_tick(void) +{ +return inl (pmtmr_ioport); +} -static uint64_t get_acpi_pm_tick (void ) {return (uint64_t )inl (pmtmr_ioport); } -static uint64_t acpi_pm_ticks_elapsed (uint64_t t1,uint64_t t2) +static uint64_t cf_check acpi_pm_ticks_elapsed(uint64_t t1, uint64_t t2) {if ( t2 >= t1 )return (t2 - t1);
@@ -664,7 +679,7 @@ void update_idle_stats(struct acpi_processor_power *power,spin_unlock (&power->stat_lock); } -static void acpi_processor_idle (void ) +static void cf_check acpi_processor_idle(void) {unsigned int cpu =smp_processor_id ();struct acpi_processor_power *power = processor_powers[cpu];
@@ -869,7 +884,7 @@ static void acpi_processor_idle(void) cpuidle_current_governor->reflect (power); } -void acpi_dead_idle (void ) +void cf_check acpi_dead_idle(void) {struct acpi_processor_power *power;struct acpi_processor_cx *cx;
xen/arch/x86/acpi/cpuidle_menu.c +3 -3
@@ -185,7 +185,7 @@ static unsigned int get_sleep_length_us(void)return (us >>32 ) ? (unsigned int )-2000 : (unsigned int )us; } -static int menu_select (struct acpi_processor_power *power) +static int cf_check menu_select(struct acpi_processor_power *power) {struct menu_device *data = &this_cpu (menu_devices);int i;
@@ -237,7 +237,7 @@ static int menu_select(struct acpi_processor_power *power)return data->last_state_idx; } -static void menu_reflect (struct acpi_processor_power *power) +static void cf_check menu_reflect(struct acpi_processor_power *power) {struct menu_device *data = &this_cpu (menu_devices);u64 new_factor;
@@ -275,7 +275,7 @@ static void menu_reflect(struct acpi_processor_power *power) data->correction_factor[data->bucket] = new_factor; } -static int menu_enable_device (struct acpi_processor_power *power) +static int cf_check menu_enable_device(struct acpi_processor_power *power) {memset (&per_cpu (menu_devices, power->cpu),0 ,sizeof (struct menu_device ));
xen/arch/x86/cpu/mwait-idle.c +1 -1
@@ -738,7 +738,7 @@ static const struct cpuidle_state dnv_cstates[] = { {} }; -static void mwait_idle (void ) +static void cf_check mwait_idle(void) {unsigned int cpu =smp_processor_id ();struct acpi_processor_power *power = processor_powers[cpu];
xen/arch/x86/domain.c +3 -3
@@ -74,11 +74,11 @@ DEFINE_PER_CPU(struct vcpu *, curr_vcpu); -static void default_idle (void ); +static void cf_check default_idle(void);void (*pm_idle) (void )__read_mostly = default_idle;void (*dead_idle) (void )__read_mostly = default_dead_idle; -static void default_idle (void ) +static void cf_check default_idle(void) {struct cpu_info *info =get_cpu_info ();
@@ -93,7 +93,7 @@ static void default_idle(void)local_irq_enable (); } -void default_dead_idle (void ) +void cf_check default_dead_idle(void) {/* * When going into S3, without flushing caches modified data may be
xen/arch/x86/hpet.c +2 -2
@@ -709,7 +709,7 @@ void hpet_disable_legacy_broadcast(void)smp_send_event_check_mask (&cpu_online_map); } -void hpet_broadcast_enter (void ) +void cf_check hpet_broadcast_enter(void) {unsigned int cpu =smp_processor_id ();struct hpet_event_channel *ch =per_cpu (cpu_bc_channel, cpu);
@@ -740,7 +740,7 @@ void hpet_broadcast_enter(void)spin_unlock (&ch->lock); } -void hpet_broadcast_exit (void ) +void cf_check hpet_broadcast_exit(void) {unsigned int cpu =smp_processor_id ();struct hpet_event_channel *ch =per_cpu (cpu_bc_channel, cpu);
xen/arch/x86/time.c +3 -3
@@ -535,7 +535,7 @@ static __init int cf_check init_pmtmr_scale(void) }__initcall (init_pmtmr_scale); -uint64_t acpi_pm_tick_to_ns (uint64_t ticks) +uint64_t cf_check acpi_pm_tick_to_ns(uint64_t ticks) {return scale_delta (ticks, &pmt_scale); }
@@ -2232,12 +2232,12 @@ static int __init cf_check disable_pit_irq(void) }__initcall (disable_pit_irq); -void pit_broadcast_enter (void ) +void cf_check pit_broadcast_enter(void) {cpumask_set_cpu (smp_processor_id (), &pit_broadcast_mask); } -void pit_broadcast_exit (void ) +void cf_check pit_broadcast_exit(void) {int cpu =smp_processor_id ();
xen/drivers/cpufreq/cpufreq_misc_governors.c +7 -7
@@ -26,8 +26,8 @@static unsigned int __read_mostly userspace_cmdline_freq; static DEFINE_PER_CPU(unsigned int, cpu_set_freq); -static int cpufreq_governor_userspace (struct cpufreq_policy *policy, -unsigned int event) +static int cf_check cpufreq_governor_userspace( +struct cpufreq_policy *policy,unsigned int event) {int ret =0 ;unsigned int cpu;
@@ -81,7 +81,7 @@ int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq)return __cpufreq_driver_target (policy, freq,CPUFREQ_RELATION_L ); } -static bool_t __init +static bool __init cf_checkcpufreq_userspace_handle_option (const char *name,const char *val) {if (!strcmp (name,"speed" ) && val) {
@@ -131,8 +131,8 @@ __initcall(cpufreq_gov_userspace_init);/* * cpufreq performance governor */ -static int cpufreq_governor_performance (struct cpufreq_policy *policy, -unsigned int event) +static int cf_check cpufreq_governor_performance( +struct cpufreq_policy *policy,unsigned int event) {int ret =0 ;
@@ -170,8 +170,8 @@ __initcall(cpufreq_gov_performance_init);/* * cpufreq powersave governor */ -static int cpufreq_governor_powersave (struct cpufreq_policy *policy, -unsigned int event) +static int cf_check cpufreq_governor_powersave( +struct cpufreq_policy *policy,unsigned int event) {int ret =0 ;
xen/include/asm-x86/cpuidle.h +2 -2
@@ -17,8 +17,8 @@ extern uint64_t (*cpuidle_get_tick)(void);int mwait_idle_init (struct notifier_block *);int cpuidle_init_cpu (unsigned int cpu); -void default_dead_idle (void ); -void acpi_dead_idle (void ); +void cf_check default_dead_idle(void); +void cf_check acpi_dead_idle(void);void play_dead (void );void trace_exit_reason (u32 *irq_traced); void update_idle_stats(struct acpi_processor_power *,
xen/include/asm-x86/hpet.h +2 -2
@@ -91,8 +91,8 @@ void hpet_disable_legacy_replacement_mode(void);*/ void hpet_broadcast_init (void );void hpet_broadcast_resume (void ); -void hpet_broadcast_enter (void ); -void hpet_broadcast_exit (void ); +void cf_check hpet_broadcast_enter(void); +void cf_check hpet_broadcast_exit(void);int hpet_broadcast_is_available (void );void hpet_disable_legacy_broadcast (void );
xen/include/asm-x86/time.h +3 -3
@@ -43,11 +43,11 @@ int hwdom_pit_access(struct ioreq *ioreq);int cpu_frequency_change (u64 freq); -void pit_broadcast_enter (void ); -void pit_broadcast_exit (void ); +void cf_check pit_broadcast_enter(void); +void cf_check pit_broadcast_exit(void);int pit_broadcast_is_available (void ); -uint64_t acpi_pm_tick_to_ns (uint64_t ticks); +uint64_t cf_check acpi_pm_tick_to_ns(uint64_t ticks);uint64_t ns_to_acpi_pm_tick (uint64_t ns);uint64_t tsc_ticks2ns (uint64_t ticks);
Signature · 1 line
2.11.0
PATCH 37/65 x86/quirks: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/dmi_scan.c | 10 +++++----- xen/arch/x86/hvm/quirks.c | 2 +- xen/arch/x86/shutdown.c | 2 +- xen/arch/x86/x86_64/mmconfig-shared.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-)
xen/arch/x86/dmi_scan.c +5 -5
@@ -476,7 +476,7 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int str#define NO_MATCH { DMI_NONE, NULL}#define MATCH DMI_MATCH -static int __init ich10_bios_quirk (const struct dmi_system_id *d) +static int __init cf_check ich10_bios_quirk(const struct dmi_system_id *d) {u32 port, smictl;
@@ -499,14 +499,14 @@ static int __init ich10_bios_quirk(const struct dmi_system_id *d)return 0 ; } -static __init int reset_videomode_after_s3 (const struct dmi_blacklist *d) +static __init int cf_check reset_videomode_after_s3(const struct dmi_blacklist *d) {/* See wakeup.S */ acpi_video_flags |=2 ;return 0 ; } -static __init int dmi_disable_acpi (const struct dmi_blacklist *d) +static __init int cf_check dmi_disable_acpi(const struct dmi_blacklist *d) {if (!acpi_force) {printk (KERN_NOTICE "%s detected: acpi off\n" ,d->ident);
@@ -521,7 +521,7 @@ static __init int dmi_disable_acpi(const struct dmi_blacklist *d)/* * Limit ACPI to CPU enumeration for HT */ -static __init int force_acpi_ht (const struct dmi_blacklist *d) +static __init int cf_check force_acpi_ht(const struct dmi_blacklist *d) {if (!acpi_force) {printk (KERN_NOTICE "%s detected: force use of acpi=ht\n" , d->ident);
@@ -650,7 +650,7 @@ static const struct dmi_blacklist __initconstrel dmi_blacklist[] = {* out of here. */ -static void __init dmi_decode (const struct dmi_header *dm) +static void __init cf_check dmi_decode(const struct dmi_header *dm) {#ifdef DMI_DEBUG const uint8_t *data = (const void *)dm;
xen/arch/x86/hvm/quirks.c +1 -1
@@ -25,7 +25,7 @@s8 __read_mostly hvm_port80_allowed =-1 ;boolean_param ("hvm_port80" , hvm_port80_allowed); -static int __init dmi_hvm_deny_port80 (const struct dmi_system_id *id) +static int __init cf_check dmi_hvm_deny_port80(const struct dmi_system_id *id) {printk (XENLOG_WARNING "%s: port 0x80 access %s allowed for HVM guests\n" , id->ident, hvm_port80_allowed >0 ?"forcibly" :"not" );
xen/arch/x86/shutdown.c +1 -1
@@ -158,7 +158,7 @@ static void default_reboot_type(void) reboot_type =BOOT_ACPI ; } -static int __init override_reboot (const struct dmi_system_id *d) +static int __init cf_check override_reboot(const struct dmi_system_id *d) {enum reboot_type type = (long )d->driver_data;
xen/arch/x86/x86_64/mmconfig-shared.c +4 -4
@@ -62,7 +62,7 @@ static int __init cf_check parse_mmcfg(const char *s) }custom_param ("mmcfg" , parse_mmcfg); -static const char __init *pci_mmcfg_e7520 (void ) +static const char *__init cf_check pci_mmcfg_e7520(void) {u32 win; win =pci_conf_read16 (PCI_SBDF (0 ,0 ,0 ,0 ),0xce );
@@ -84,7 +84,7 @@ static const char __init *pci_mmcfg_e7520(void)return "Intel Corporation E7520 Memory Controller Hub" ; } -static const char __init *pci_mmcfg_intel_945 (void ) +static const char *__init cf_check pci_mmcfg_intel_945(void) {u32 pciexbar, mask =0 , len =0 ;
@@ -137,7 +137,7 @@ static const char __init *pci_mmcfg_intel_945(void)return "Intel Corporation 945G/GZ/P/PL Express Memory Controller Hub" ; } -static const char __init *pci_mmcfg_amd_fam10h (void ) +static const char *__init cf_check pci_mmcfg_amd_fam10h(void) {uint32_t address;uint64_t base, msr_content;
@@ -190,7 +190,7 @@ static const char __init *pci_mmcfg_amd_fam10h(void)return "AMD Family 10h NB" ; } -static const char __init *pci_mmcfg_nvidia_mcp55 (void ) +static const char *__init cf_check pci_mmcfg_nvidia_mcp55(void) {static bool_t __initdata mcp55_checked;int bus, i;
Signature · 1 line
2.11.0
PATCH 38/65 x86/hvmsave: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/emul-i8254.c | 4 ++-- xen/arch/x86/hvm/hpet.c | 4 ++-- xen/arch/x86/hvm/hvm.c | 18 ++++++++++-------- xen/arch/x86/hvm/irq.c | 12 ++++++------ xen/arch/x86/hvm/mtrr.c | 4 ++-- xen/arch/x86/hvm/pmtimer.c | 4 ++-- xen/arch/x86/hvm/rtc.c | 4 ++-- xen/arch/x86/hvm/vioapic.c | 4 ++-- xen/arch/x86/hvm/viridian/viridian.c | 15 ++++++++------- xen/arch/x86/hvm/vlapic.c | 8 ++++---- xen/arch/x86/hvm/vpic.c | 4 ++-- 12 files changed, 44 insertions(+), 41 deletions(-)
xen/arch/x86/cpu/mcheck/vmce.c +2 -2
@@ -353,7 +353,7 @@ int vmce_wrmsr(uint32_t msr, uint64_t val) } #if CONFIG_HVM -static int vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) +static int cf_check vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) { struct hvm_vmce_vcpu ctxt = { .caps = v->arch.vmce.mcg_cap,
@@ -365,7 +365,7 @@ static int vmce_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (VMCE_VCPU , v->vcpu_id, h, &ctxt); } -static int vmce_load_vcpu_ctxt (struct domain *d,hvm_domain_context_t *h) +static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
xen/arch/x86/emul-i8254.c +2 -2
@@ -391,7 +391,7 @@ void pit_stop_channel0_irq(PITState *pit)spin_unlock (&pit->lock); } -static int pit_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check pit_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;PITState *pit =domain_vpit (d);
@@ -409,7 +409,7 @@ static int pit_save(struct vcpu *v, hvm_domain_context_t *h)return rc; } -static int pit_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h) {PITState *pit =domain_vpit (d);int i, rc =0 ;
xen/arch/x86/hvm/hpet.c +2 -2
@@ -582,7 +582,7 @@ static const struct hvm_mmio_ops hpet_mmio_ops = { }; -static int hpet_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hpet_save(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;HPETState *hp =domain_vhpet (d);
@@ -645,7 +645,7 @@ static int hpet_save(struct vcpu *v, hvm_domain_context_t *h)return rc; } -static int hpet_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check hpet_load(struct domain *d, hvm_domain_context_t *h) {HPETState *hp =domain_vhpet (d);struct hvm_hw_hpet *rec;
xen/arch/x86/hvm/hvm.c +10 -8
@@ -789,7 +789,7 @@ void hvm_domain_destroy(struct domain *d)destroy_vpci_mmcfg (d); } -static int hvm_save_tsc_adjust (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hvm_save_tsc_adjust(struct vcpu *v, hvm_domain_context_t *h) {struct hvm_tsc_adjust ctxt = { .tsc_adjust = v->arch.hvm.msr_tsc_adjust,
@@ -798,7 +798,7 @@ static int hvm_save_tsc_adjust(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (TSC_ADJUST , v->vcpu_id, h, &ctxt); } -static int hvm_load_tsc_adjust (struct domain *d,hvm_domain_context_t *h) +static int cf_check hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
@@ -821,7 +821,7 @@ static int hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h)HVM_REGISTER_SAVE_RESTORE (TSC_ADJUST , hvm_save_tsc_adjust, hvm_load_tsc_adjust,1 ,HVMSR_PER_VCPU ); -static int hvm_save_cpu_ctxt (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hvm_save_cpu_ctxt(struct vcpu *v, hvm_domain_context_t *h) {struct segment_register seg;struct hvm_hw_cpu ctxt = {
@@ -1004,7 +1004,7 @@ unsigned long hvm_cr4_guest_valid_bits(const struct domain *d) (cet ? X86_CR4_CET : 0)); } -static int hvm_load_cpu_ctxt (struct domain *d,hvm_domain_context_t *h) +static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
@@ -1205,7 +1205,8 @@ HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, hvm_load_cpu_ctxt, 1, save_area) + \ xstate_ctxt_size(xcr0)) -static int hvm_save_cpu_xsave_states (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hvm_save_cpu_xsave_states( +struct vcpu *v,hvm_domain_context_t *h) {struct hvm_hw_cpu_xsave *ctxt;unsigned int size =HVM_CPU_XSAVE_SIZE (v->arch.xcr0_accum);
@@ -1243,7 +1244,8 @@ CHECK_FIELD_(struct, xsave_hdr, reserved);#undef compat_xsave_hdr#undef xen_xsave_hdr -static int hvm_load_cpu_xsave_states (struct domain *d,hvm_domain_context_t *h) +static int cf_check hvm_load_cpu_xsave_states( +struct domain *d,hvm_domain_context_t *h) {unsigned int vcpuid, size;int err;
@@ -1371,7 +1373,7 @@ static const uint32_t msrs_to_send[] = { MSR_AMD64_DR3_ADDRESS_MASK, }; -static int hvm_save_cpu_msrs (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hvm_save_cpu_msrs(struct vcpu *v, hvm_domain_context_t *h) {struct hvm_save_descriptor *desc =_p (&h->data[h->cur]);struct hvm_msr *ctxt;
@@ -1430,7 +1432,7 @@ static int hvm_save_cpu_msrs(struct vcpu *v, hvm_domain_context_t *h)return 0 ; } -static int hvm_load_cpu_msrs (struct domain *d,hvm_domain_context_t *h) +static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) {unsigned int i, vcpuid =hvm_load_instance (h);struct vcpu *v;
xen/arch/x86/hvm/irq.c +6 -6
@@ -657,7 +657,7 @@ static int __init cf_check dump_irq_info_key_init(void) }__initcall (dump_irq_info_key_init); -static int irq_save_pci (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check irq_save_pci(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;struct hvm_irq *hvm_irq =hvm_domain_irq (d);
@@ -690,7 +690,7 @@ static int irq_save_pci(struct vcpu *v, hvm_domain_context_t *h)return rc; } -static int irq_save_isa (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check irq_save_isa(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;struct hvm_irq *hvm_irq =hvm_domain_irq (d);
@@ -699,7 +699,7 @@ static int irq_save_isa(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (ISA_IRQ ,0 , h, &hvm_irq->isa_irq); } -static int irq_save_link (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check irq_save_link(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;struct hvm_irq *hvm_irq =hvm_domain_irq (d);
@@ -708,7 +708,7 @@ static int irq_save_link(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (PCI_LINK ,0 , h, &hvm_irq->pci_link); } -static int irq_load_pci (struct domain *d,hvm_domain_context_t *h) +static int cf_check irq_load_pci(struct domain *d, hvm_domain_context_t *h) {struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi;
@@ -741,7 +741,7 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)return 0 ; } -static int irq_load_isa (struct domain *d,hvm_domain_context_t *h) +static int cf_check irq_load_isa(struct domain *d, hvm_domain_context_t *h) {struct hvm_irq *hvm_irq =hvm_domain_irq (d);int irq;
@@ -760,7 +760,7 @@ static int irq_load_isa(struct domain *d, hvm_domain_context_t *h) } -static int irq_load_link (struct domain *d,hvm_domain_context_t *h) +static int cf_check irq_load_link(struct domain *d, hvm_domain_context_t *h) {struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, gsi;
xen/arch/x86/hvm/mtrr.c +2 -2
@@ -687,7 +687,7 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,return 0 ; } -static int hvm_save_mtrr_msr (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check hvm_save_mtrr_msr(struct vcpu *v, hvm_domain_context_t *h) {const struct mtrr_state *mtrr_state = &v->arch.hvm.mtrr;struct hvm_hw_mtrr hw_mtrr = {
@@ -725,7 +725,7 @@ static int hvm_save_mtrr_msr(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (MTRR , v->vcpu_id, h, &hw_mtrr); } -static int hvm_load_mtrr_msr (struct domain *d,hvm_domain_context_t *h) +static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid, i;struct vcpu *v;
xen/arch/x86/hvm/pmtimer.c +2 -2
@@ -249,7 +249,7 @@ static int cf_check handle_pmt_io(return X86EMUL_OKAY ; } -static int acpi_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check acpi_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;struct hvm_hw_acpi *acpi = &d->arch.hvm.acpi;
@@ -281,7 +281,7 @@ static int acpi_save(struct vcpu *v, hvm_domain_context_t *h)return rc; } -static int acpi_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check acpi_load(struct domain *d, hvm_domain_context_t *h) {struct hvm_hw_acpi *acpi = &d->arch.hvm.acpi;PMTState *s = &d->arch.hvm.pl_time->vpmt;
xen/arch/x86/hvm/rtc.c +2 -2
@@ -738,7 +738,7 @@ void rtc_migrate_timers(struct vcpu *v) }/* Save RTC hardware state */ -static int rtc_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check rtc_save(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;RTCState *s =domain_vrtc (d);
@@ -756,7 +756,7 @@ static int rtc_save(struct vcpu *v, hvm_domain_context_t *h) }/* Reload the hardware state from a saved domain */ -static int rtc_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check rtc_load(struct domain *d, hvm_domain_context_t *h) {RTCState *s =domain_vrtc (d);
xen/arch/x86/hvm/vioapic.c +2 -2
@@ -590,7 +590,7 @@ int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi)return vioapic->redirtbl[pin].fields.trig_mode; } -static int ioapic_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check ioapic_save(struct vcpu *v, hvm_domain_context_t *h) {const struct domain *d = v->domain;struct hvm_vioapic *s;
@@ -607,7 +607,7 @@ static int ioapic_save(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (IOAPIC ,0 , h, &s->domU); } -static int ioapic_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check ioapic_load(struct domain *d, hvm_domain_context_t *h) {struct hvm_vioapic *s;
xen/arch/x86/hvm/viridian/viridian.c +8 -7
@@ -1125,8 +1125,8 @@ void viridian_unmap_guest_page(struct viridian_page *vp)put_page_and_type (page); } -static int viridian_save_domain_ctxt (struct vcpu *v, -hvm_domain_context_t *h) +static int cf_check viridian_save_domain_ctxt( +struct vcpu *v,hvm_domain_context_t *h) {const struct domain *d = v->domain;const struct viridian_domain *vd = d->arch.hvm.viridian;
@@ -1144,8 +1144,8 @@ static int viridian_save_domain_ctxt(struct vcpu *v,return (hvm_save_entry (VIRIDIAN_DOMAIN ,0 , h, &ctxt) !=0 ); } -static int viridian_load_domain_ctxt (struct domain *d, -hvm_domain_context_t *h) +static int cf_check viridian_load_domain_ctxt( +struct domain *d,hvm_domain_context_t *h) {struct viridian_domain *vd = d->arch.hvm.viridian;struct hvm_viridian_domain_context ctxt;
@@ -1165,7 +1165,8 @@ static int viridian_load_domain_ctxt(struct domain *d,HVM_REGISTER_SAVE_RESTORE (VIRIDIAN_DOMAIN , viridian_save_domain_ctxt, viridian_load_domain_ctxt,1 ,HVMSR_PER_DOM ); -static int viridian_save_vcpu_ctxt (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check viridian_save_vcpu_ctxt( +struct vcpu *v,hvm_domain_context_t *h) {struct hvm_viridian_vcpu_context ctxt = {};
@@ -1178,8 +1179,8 @@ static int viridian_save_vcpu_ctxt(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (VIRIDIAN_VCPU , v->vcpu_id, h, &ctxt); } -static int viridian_load_vcpu_ctxt (struct domain *d, -hvm_domain_context_t *h) +static int cf_check viridian_load_vcpu_ctxt( +struct domain *d,hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
xen/arch/x86/hvm/vlapic.c +4 -4
@@ -1482,7 +1482,7 @@ static void lapic_rearm(struct vlapic *s) s->timer_last_update = s->pt.last_plt_gtime; } -static int lapic_save_hidden (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check lapic_save_hidden(struct vcpu *v, hvm_domain_context_t *h) {if ( !has_vlapic (v->domain) )return 0 ;
@@ -1490,7 +1490,7 @@ static int lapic_save_hidden(struct vcpu *v, hvm_domain_context_t *h)return hvm_save_entry (LAPIC , v->vcpu_id, h, &vcpu_vlapic (v)->hw); } -static int lapic_save_regs (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check lapic_save_regs(struct vcpu *v, hvm_domain_context_t *h) {if ( !has_vlapic (v->domain) )return 0 ;
@@ -1529,7 +1529,7 @@ static void lapic_load_fixup(struct vlapic *vlapic) } } -static int lapic_load_hidden (struct domain *d,hvm_domain_context_t *h) +static int cf_check lapic_load_hidden(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
@@ -1563,7 +1563,7 @@ static int lapic_load_hidden(struct domain *d, hvm_domain_context_t *h)return 0 ; } -static int lapic_load_regs (struct domain *d,hvm_domain_context_t *h) +static int cf_check lapic_load_regs(struct domain *d, hvm_domain_context_t *h) {unsigned int vcpuid =hvm_load_instance (h);struct vcpu *v;
xen/arch/x86/hvm/vpic.c +2 -2
@@ -400,7 +400,7 @@ static int cf_check vpic_intercept_elcr_io(return X86EMUL_OKAY ; } -static int vpic_save (struct vcpu *v,hvm_domain_context_t *h) +static int cf_check vpic_save(struct vcpu *v, hvm_domain_context_t *h) {struct domain *d = v->domain;struct hvm_hw_vpic *s;
@@ -420,7 +420,7 @@ static int vpic_save(struct vcpu *v, hvm_domain_context_t *h)return 0 ; } -static int vpic_load (struct domain *d,hvm_domain_context_t *h) +static int cf_check vpic_load(struct domain *d, hvm_domain_context_t *h) {struct hvm_hw_vpic *s;unsigned int inst =hvm_load_instance (h);
Signature · 1 line
2.11.0
PATCH 39/65 x86/mce: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/mcheck/mce.c | 8 ++++---- xen/arch/x86/cpu/mcheck/mce.h | 2 +- xen/arch/x86/cpu/mcheck/mce_amd.c | 9 ++++---- xen/arch/x86/cpu/mcheck/mce_amd.h | 4 ++-- xen/arch/x86/cpu/mcheck/mce_intel.c | 41 +++++++++++++++++-------------------- 5 files changed, 31 insertions(+), 33 deletions(-)
xen/arch/x86/cpu/mcheck/mce.c +4 -4
@@ -75,7 +75,7 @@ static int __init cf_check mce_set_verbosity(const char *str)custom_param ("mce_verbosity" , mce_set_verbosity);/* Handle unconfigured int18 (should never happen) */ -static void unexpected_machine_check (const struct cpu_user_regs *regs) +static void cf_check unexpected_machine_check(const struct cpu_user_regs *regs) {console_force_unlock ();printk ("Unexpected Machine Check Exception\n" );
@@ -469,7 +469,7 @@ static int mce_urgent_action(const struct cpu_user_regs *regs, }/* Shared #MC handler. */ -void mcheck_cmn_handler (const struct cpu_user_regs *regs) +void cf_check mcheck_cmn_handler(const struct cpu_user_regs *regs) {static DEFINE_MCE_BARRIER (mce_trap_bar);static atomic_t severity_cpu =ATOMIC_INIT (-1 );
@@ -1684,7 +1684,7 @@ long cf_check do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) }int mcinfo_dumpped; -static int x86_mcinfo_dump_panic (mctelem_cookie_t mctc) +static int cf_check x86_mcinfo_dump_panic(mctelem_cookie_t mctc) {struct mc_info *mcip =mctelem_dataptr (mctc);
@@ -1801,7 +1801,7 @@ static enum mce_result mce_action(const struct cpu_user_regs *regs,* should be committed for dom0 consumption, 0 if it should be * dismissed. */ -static int mce_delayed_action (mctelem_cookie_t mctc) +static int cf_check mce_delayed_action(mctelem_cookie_t mctc) {enum mce_result result;int ret =0 ;
xen/arch/x86/cpu/mcheck/mce.h +1 -1
@@ -70,7 +70,7 @@ 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 (const struct cpu_user_regs *regs); +void cf_check mcheck_cmn_handler(const struct cpu_user_regs *regs);/* Register a handler for judging whether mce is recoverable. */ typedef bool (*mce_recoverable_t )(uint64_t status);
xen/arch/x86/cpu/mcheck/mce_amd.c +5 -4
@@ -113,7 +113,7 @@ mc_ec2type(uint16_t errorcode)return 0 ; } -bool mc_amd_recoverable_scan (uint64_t status) +bool cf_check mc_amd_recoverable_scan(uint64_t status) {bool ret = false;enum mc_ec_type ectype;
@@ -143,7 +143,7 @@ bool mc_amd_recoverable_scan(uint64_t status)return ret; } -bool mc_amd_addrcheck (uint64_t status,uint64_t misc,int addrtype) +bool cf_check mc_amd_addrcheck(uint64_t status, uint64_t misc, int addrtype) {enum mc_ec_type ectype;uint16_t errorcode;
@@ -216,7 +216,7 @@ static void mcequirk_amd_apply(enum mcequirk_amd_flags flags) } } -static struct mcinfo_extended * +static struct mcinfo_extended *cf_checkamd_f10_handler (struct mc_info *mi,uint16_t bank,uint64_t status) {struct mcinfo_extended *mc_ext;
@@ -252,7 +252,8 @@ amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status)return mc_ext; } -static bool amd_need_clearbank_scan (enum mca_source who,uint64_t status) +static bool cf_check amd_need_clearbank_scan( +enum mca_source who,uint64_t status) {if ( who !=MCA_MCE_SCAN )return true;
xen/arch/x86/cpu/mcheck/mce_amd.h +2 -2
@@ -1,7 +1,7 @@#ifndef _MCHECK_AMD_H#define _MCHECK_AMD_H -bool mc_amd_recoverable_scan (uint64_t status); -bool mc_amd_addrcheck (uint64_t status,uint64_t misc,int addrtype); +bool cf_check mc_amd_recoverable_scan(uint64_t status); +bool cf_check mc_amd_addrcheck(uint64_t status, uint64_t misc, int addrtype);#endif
xen/arch/x86/cpu/mcheck/mce_intel.c +19 -22
95 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 40/65 x86/pmu: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/vpmu_amd.c | 16 ++++++++-------- xen/arch/x86/cpu/vpmu_intel.c | 16 ++++++++-------- xen/arch/x86/oprofile/op_model_athlon.c | 16 ++++++++-------- xen/arch/x86/oprofile/op_model_p4.c | 14 +++++++------- xen/arch/x86/oprofile/op_model_ppro.c | 26 ++++++++++++++------------ 5 files changed, 45 insertions(+), 43 deletions(-)
xen/arch/x86/cpu/vpmu_amd.c +8 -8
@@ -186,7 +186,7 @@ static void amd_vpmu_unset_msr_bitmap(struct vcpu *v)msr_bitmap_off (vpmu); } -static int amd_vpmu_do_interrupt (struct cpu_user_regs *regs) +static int cf_check amd_vpmu_do_interrupt(struct cpu_user_regs *regs) {return 1 ; }
@@ -206,7 +206,7 @@ static inline void context_load(struct vcpu *v) } } -static int amd_vpmu_load (struct vcpu *v,bool_t from_guest) +static int cf_check amd_vpmu_load(struct vcpu *v, bool from_guest) {struct vpmu_struct *vpmu =vcpu_vpmu (v);struct xen_pmu_amd_ctxt *ctxt;
@@ -280,7 +280,7 @@ static inline void context_save(struct vcpu *v)rdmsrl (counters[i], counter_regs[i]); } -static int amd_vpmu_save (struct vcpu *v,bool_t to_guest) +static int cf_check amd_vpmu_save(struct vcpu *v, bool to_guest) {struct vpmu_struct *vpmu =vcpu_vpmu (v);unsigned int i;
@@ -348,8 +348,8 @@ static void context_update(unsigned int msr, u64 msr_content) } } -static int amd_vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content, -uint64_t supported) +static int cf_check amd_vpmu_do_wrmsr( +unsigned int msr,uint64_t msr_content,uint64_t supported) {struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -407,7 +407,7 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,return 0 ; } -static int amd_vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_content) +static int cf_check amd_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content) {struct vcpu *v = current;struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -425,7 +425,7 @@ static int amd_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)return 0 ; } -static void amd_vpmu_destroy (struct vcpu *v) +static void cf_check amd_vpmu_destroy(struct vcpu *v) {struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -443,7 +443,7 @@ static void amd_vpmu_destroy(struct vcpu *v) }/* VPMU part of the 'q' keyhandler */ -static void amd_vpmu_dump (const struct vcpu *v) +static void cf_check amd_vpmu_dump(const struct vcpu *v) {const struct vpmu_struct *vpmu =vcpu_vpmu (v);const struct xen_pmu_amd_ctxt *ctxt = vpmu->context;
xen/arch/x86/cpu/vpmu_intel.c +8 -8
@@ -288,7 +288,7 @@ static inline void __core2_vpmu_save(struct vcpu *v)rdmsrl (MSR_CORE_PERF_GLOBAL_STATUS , core2_vpmu_cxt->global_status); } -static int core2_vpmu_save (struct vcpu *v,bool_t to_guest) +static int cf_check core2_vpmu_save(struct vcpu *v, bool to_guest) {struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -407,7 +407,7 @@ static int core2_vpmu_verify(struct vcpu *v)return 0 ; } -static int core2_vpmu_load (struct vcpu *v,bool_t from_guest) +static int cf_check core2_vpmu_load(struct vcpu *v, bool from_guest) {struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -522,8 +522,8 @@ static int core2_vpmu_msr_common_check(u32 msr_index, int *type, int *index)return 1 ; } -static int core2_vpmu_do_wrmsr (unsigned int msr,uint64_t msr_content, -uint64_t supported) +static int cf_check core2_vpmu_do_wrmsr( +unsigned int msr,uint64_t msr_content,uint64_t supported) {int i, tmp;int type =-1 , index =-1 ;
@@ -693,7 +693,7 @@ static int core2_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,return 0 ; } -static int core2_vpmu_do_rdmsr (unsigned int msr,uint64_t *msr_content) +static int cf_check core2_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content) {int type =-1 , index =-1 ;struct vcpu *v = current;
@@ -733,7 +733,7 @@ static int core2_vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content) }/* Dump vpmu info on console, called in the context of keyhandler 'q'. */ -static void core2_vpmu_dump (const struct vcpu *v) +static void cf_check core2_vpmu_dump(const struct vcpu *v) {const struct vpmu_struct *vpmu =vcpu_vpmu (v);unsigned int i;
@@ -778,7 +778,7 @@ static void core2_vpmu_dump(const struct vcpu *v) } } -static int core2_vpmu_do_interrupt (struct cpu_user_regs *regs) +static int cf_check core2_vpmu_do_interrupt(struct cpu_user_regs *regs) {struct vcpu *v = current;u64 msr_content;
@@ -805,7 +805,7 @@ static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)return 1 ; } -static void core2_vpmu_destroy (struct vcpu *v) +static void cf_check core2_vpmu_destroy(struct vcpu *v) {struct vpmu_struct *vpmu =vcpu_vpmu (v);
xen/arch/x86/oprofile/op_model_athlon.c +8 -8
@@ -164,7 +164,7 @@ static inline u64 op_amd_randomize_ibs_op(u64 val)return val; } -static void athlon_fill_in_addresses (struct op_msrs *const msrs) +static void cf_check athlon_fill_in_addresses(struct op_msrs * const msrs) { msrs->counters[0 ].addr =MSR_K7_PERFCTR0 ; msrs->counters[1 ].addr =MSR_K7_PERFCTR1 ;
@@ -177,7 +177,7 @@ static void athlon_fill_in_addresses(struct op_msrs * const msrs) msrs->controls[3 ].addr =MSR_K7_EVNTSEL3 ; } -static void fam15h_fill_in_addresses (struct op_msrs *const msrs) +static void cf_check fam15h_fill_in_addresses(struct op_msrs * const msrs) { msrs->counters[0 ].addr =MSR_AMD_FAM15H_PERFCTR0 ; msrs->counters[1 ].addr =MSR_AMD_FAM15H_PERFCTR1 ;
@@ -194,7 +194,7 @@ static void fam15h_fill_in_addresses(struct op_msrs * const msrs) msrs->controls[5 ].addr =MSR_AMD_FAM15H_EVNTSEL5 ; } -static void athlon_setup_ctrs (struct op_msrs const *const msrs) +static void cf_check athlon_setup_ctrs(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
@@ -308,9 +308,9 @@ static inline int handle_ibs(int mode, struct cpu_user_regs const * const regs)return 1 ; } -static int athlon_check_ctrs (unsigned int const cpu, -struct op_msrs const *const msrs, -struct cpu_user_regs const *const regs) +static int cf_check athlon_check_ctrs( +unsigned int const cpu,struct op_msrs const *const msrs, +struct cpu_user_regs const *const regs) {uint64_t msr_content;
@@ -386,7 +386,7 @@ static inline void start_ibs(void) } } -static void athlon_start (struct op_msrs const *const msrs) +static void cf_check athlon_start(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
@@ -415,7 +415,7 @@ static void stop_ibs(void)wrmsrl (MSR_AMD64_IBSOPCTL ,0 ); } -static void athlon_stop (struct op_msrs const *const msrs) +static void cf_check athlon_stop(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
xen/arch/x86/oprofile/op_model_p4.c +7 -7
@@ -390,7 +390,7 @@ static unsigned int get_stagger(void)static unsigned long reset_value[NUM_COUNTERS_NON_HT ]; -static void p4_fill_in_addresses (struct op_msrs *const msrs) +static void cf_check p4_fill_in_addresses(struct op_msrs * const msrs) {unsigned int i;unsigned int addr, stag;
@@ -530,7 +530,7 @@ static void pmc_setup_one_p4_counter(unsigned int ctr) } -static void p4_setup_ctrs (struct op_msrs const *const msrs) +static void cf_check p4_setup_ctrs(struct op_msrs const * const msrs) {unsigned int i;uint64_t msr_content;
@@ -609,9 +609,9 @@ 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 *const regs) +static int cf_check p4_check_ctrs( +unsigned int const cpu,struct op_msrs const *const msrs, +struct cpu_user_regs const *const regs) {unsigned long ctr, stag, real;uint64_t msr_content;
@@ -665,7 +665,7 @@ static int p4_check_ctrs(unsigned int const cpu, } -static void p4_start (struct op_msrs const *const msrs) +static void cf_check p4_start(struct op_msrs const * const msrs) {unsigned int stag;uint64_t msr_content;
@@ -683,7 +683,7 @@ static void p4_start(struct op_msrs const * const msrs) } -static void p4_stop (struct op_msrs const *const msrs) +static void cf_check p4_stop(struct op_msrs const * const msrs) {unsigned int stag;uint64_t msr_content;
xen/arch/x86/oprofile/op_model_ppro.c +14 -12
@@ -63,7 +63,7 @@ static int counter_width = 32;static unsigned long reset_value[OP_MAX_COUNTER ];int ppro_has_global_ctrl =0 ; -static void ppro_fill_in_addresses (struct op_msrs *const msrs) +static void cf_check ppro_fill_in_addresses(struct op_msrs * const msrs) {int i;
@@ -74,7 +74,7 @@ static void ppro_fill_in_addresses(struct op_msrs * const msrs) } -static void ppro_setup_ctrs (struct op_msrs const *const msrs) +static void cf_check ppro_setup_ctrs(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
@@ -128,9 +128,9 @@ 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 *const regs) +static int cf_check ppro_check_ctrs( +unsigned int const cpu,struct op_msrs const *const msrs, +struct cpu_user_regs const *const regs) {u64 val;int i;
@@ -170,7 +170,7 @@ static int ppro_check_ctrs(unsigned int const cpu, } -static void ppro_start (struct op_msrs const *const msrs) +static void cf_check ppro_start(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
@@ -190,7 +190,7 @@ static void ppro_start(struct op_msrs const * const msrs) } -static void ppro_stop (struct op_msrs const *const msrs) +static void cf_check ppro_stop(struct op_msrs const * const msrs) {uint64_t msr_content;int i;
@@ -206,7 +206,7 @@ static void ppro_stop(struct op_msrs const * const msrs)wrmsrl (MSR_CORE_PERF_GLOBAL_CTRL ,0x0ULL ); } -static int ppro_is_arch_pmu_msr (u64 msr_index,int *type,int *index) +static int cf_check ppro_is_arch_pmu_msr(u64 msr_index, int *type, int *index) {if ( (msr_index >=MSR_IA32_PERFCTR0 ) && (msr_index < (MSR_IA32_PERFCTR0 + num_counters)) )
@@ -226,7 +226,7 @@ static int ppro_is_arch_pmu_msr(u64 msr_index, int *type, int *index)return 0 ; } -static int ppro_allocate_msr (struct vcpu *v) +static int cf_check ppro_allocate_msr(struct vcpu *v) {struct vpmu_struct *vpmu =vcpu_vpmu (v);struct arch_msr_pair *msr_content;
@@ -245,7 +245,7 @@ static int ppro_allocate_msr(struct vcpu *v)return 0 ; } -static void ppro_free_msr (struct vcpu *v) +static void cf_check ppro_free_msr(struct vcpu *v) {struct vpmu_struct *vpmu =vcpu_vpmu (v);
@@ -255,7 +255,8 @@ static void ppro_free_msr(struct vcpu *v)vpmu_reset (vpmu,VPMU_PASSIVE_DOMAIN_ALLOCATED ); } -static void ppro_load_msr (struct vcpu *v,int type,int index,u64 *msr_content) +static void cf_check ppro_load_msr( +struct vcpu *v,int type,int index,u64 *msr_content) {struct arch_msr_pair *msrs =vcpu_vpmu (v)->context; switch ( type )
@@ -269,7 +270,8 @@ static void ppro_load_msr(struct vcpu *v, int type, int index, u64 *msr_content) } } -static void ppro_save_msr (struct vcpu *v,int type,int index,u64 msr_content) +static void cf_check ppro_save_msr( +struct vcpu *v,int type,int index,u64 msr_content) {struct arch_msr_pair *msrs =vcpu_vpmu (v)->context;
Signature · 1 line
2.11.0
PATCH 41/65 x86/cpu: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/amd.c | 6 +++--- xen/arch/x86/cpu/centaur.c | 2 +- xen/arch/x86/cpu/common.c | 2 +- xen/arch/x86/cpu/cpu.h | 2 +- xen/arch/x86/cpu/hygon.c | 2 +- xen/arch/x86/cpu/intel.c | 6 +++--- xen/arch/x86/cpu/shanghai.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-)
xen/arch/x86/cpu/amd.c +3 -3
@@ -208,7 +208,7 @@ static void __init noinline probe_masking_msrs(void)* parameter of NULL is used to context switch to the default host state (by * the cpu bringup-code, crash path, etc). */ -static void amd_ctxt_switch_masking (const struct vcpu *next) +static void cf_check amd_ctxt_switch_masking(const struct vcpu *next) {struct cpuidmasks *these_masks = &this_cpu (cpuidmasks);const struct domain *nextd = next ? next->domain :NULL ;
@@ -634,7 +634,7 @@ void amd_log_freq(const struct cpuinfo_x86 *c)#undef FREQ } -void early_init_amd (struct cpuinfo_x86 *c) +void cf_check early_init_amd(struct cpuinfo_x86 *c) {if (c == &boot_cpu_data)amd_init_levelling ();
@@ -744,7 +744,7 @@ void __init detect_zen2_null_seg_behaviour(void) } -static void init_amd (struct cpuinfo_x86 *c) +static void cf_check init_amd(struct cpuinfo_x86 *c) {u32 l, h;
xen/arch/x86/cpu/centaur.c +1 -1
@@ -48,7 +48,7 @@ static void init_c3(struct cpuinfo_x86 *c)display_cacheinfo (c); } -static void init_centaur (struct cpuinfo_x86 *c) +static void cf_check init_centaur(struct cpuinfo_x86 *c) {if (c->x86 ==6 )init_c3 (c);
xen/arch/x86/cpu/common.c +1 -1
@@ -104,7 +104,7 @@ bool __init is_forced_cpu_cap(unsigned int cap)return test_bit (cap, forced_caps); } -static void default_init (struct cpuinfo_x86 * c) +static void cf_check default_init(struct cpuinfo_x86 * c) {/* Not much we can do here... */ /* Check if at least it has cpuid */
xen/arch/x86/cpu/cpu.h +1 -1
@@ -18,7 +18,7 @@ extern void display_cacheinfo(struct cpuinfo_x86 *c);extern void detect_ht (struct cpuinfo_x86 *c);extern bool detect_extended_topology (struct cpuinfo_x86 *c); -void early_init_amd (struct cpuinfo_x86 *c); +void cf_check early_init_amd(struct cpuinfo_x86 *c);void amd_log_freq (const struct cpuinfo_x86 *c);void amd_init_lfence (struct cpuinfo_x86 *c);void amd_init_ssbd (const struct cpuinfo_x86 *c);
xen/arch/x86/cpu/hygon.c +1 -1
@@ -28,7 +28,7 @@ static void hygon_get_topology(struct cpuinfo_x86 *c) c->phys_proc_id, c->cpu_core_id); } -static void init_hygon (struct cpuinfo_x86 *c) +static void cf_check init_hygon(struct cpuinfo_x86 *c) {unsigned long long value;
xen/arch/x86/cpu/intel.c +3 -3
@@ -144,7 +144,7 @@ static void __init probe_masking_msrs(void)* parameter of NULL is used to context switch to the default host state (by * the cpu bringup-code, crash path, etc). */ -static void intel_ctxt_switch_masking (const struct vcpu *next) +static void cf_check intel_ctxt_switch_masking(const struct vcpu *next) {struct cpuidmasks *these_masks = &this_cpu (cpuidmasks);const struct domain *nextd = next ? next->domain :NULL ;
@@ -254,7 +254,7 @@ static void __init noinline intel_init_levelling(void) ctxt_switch_masking = intel_ctxt_switch_masking; } -static void early_init_intel (struct cpuinfo_x86 *c) +static void cf_check early_init_intel(struct cpuinfo_x86 *c) {u64 misc_enable, disable;
@@ -448,7 +448,7 @@ static void intel_log_freq(const struct cpuinfo_x86 *c) } } -static void init_intel (struct cpuinfo_x86 *c) +static void cf_check init_intel(struct cpuinfo_x86 *c) {/* Detect the extended topology information if available */ detect_extended_topology (c);
xen/arch/x86/cpu/shanghai.c +1 -1
@@ -3,7 +3,7 @@#include <asm/processor.h> #include "cpu.h" -static void init_shanghai (struct cpuinfo_x86 *c) +static void cf_check init_shanghai(struct cpuinfo_x86 *c) {if (cpu_has (c,X86_FEATURE_ITSC ) ) {
Signature · 1 line
2.11.0
PATCH 42/65 x86/guest: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/guest/hyperv/hyperv.c | 10 +++++----- xen/arch/x86/guest/xen/xen.c | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-)
xen/arch/x86/guest/hyperv/hyperv.c +5 -5
@@ -175,7 +175,7 @@ static int setup_vp_assist(void)return 0 ; } -static void __init setup (void ) +static void __init cf_check setup(void) {ASM_CONSTANT (HV_HCALL_PAGE ,__fix_x_to_virt (FIX_X_HYPERV_HCALL ));
@@ -188,7 +188,7 @@ static void __init setup(void)panic ("VP assist page setup failed\n" ); } -static int ap_setup (void ) +static int cf_check ap_setup(void) {int rc;
@@ -199,7 +199,7 @@ static int ap_setup(void)return setup_vp_assist (); } -static void __init e820_fixup (struct e820map *e820) +static void __init cf_check e820_fixup(struct e820map *e820) {uint64_t s =HV_HCALL_MFN <<PAGE_SHIFT ;
@@ -207,8 +207,8 @@ static void __init e820_fixup(struct e820map *e820)panic ("Unable to reserve Hyper-V hypercall range\n" ); } -static int flush_tlb (const cpumask_t *mask,const void *va, -unsigned int flags) +static int cf_check flush_tlb( +const cpumask_t *mask,const void *va,unsigned int flags) {if ( !(ms_hyperv.hints &HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED ) )return -EOPNOTSUPP ;
xen/arch/x86/guest/xen/xen.c +6 -5
@@ -237,7 +237,7 @@ static int init_evtchn(void)return rc; } -static void __init setup (void ) +static void __init cf_check setup(void) {init_memmap ();
@@ -265,7 +265,7 @@ static void __init setup(void)BUG_ON (init_evtchn ()); } -static int ap_setup (void ) +static int cf_check ap_setup(void) {set_vcpu_id ();
@@ -295,7 +295,7 @@ static void cf_check ap_resume(void *unused)BUG_ON (init_evtchn ()); } -static void resume (void ) +static void cf_check resume(void) {/* Reset shared info page. */ map_shared_info ();
@@ -318,13 +318,14 @@ static void resume(void)pv_console_init (); } -static void __init e820_fixup (struct e820map *e820) +static void __init cf_check e820_fixup(struct e820map *e820) {if ( pv_shim )pv_shim_fixup_e820 (e820); } -static int flush_tlb (const cpumask_t *mask,const void *va,unsigned int flags) +static int cf_check flush_tlb( +const cpumask_t *mask,const void *va,unsigned int flags) {return xen_hypercall_hvm_op (HVMOP_flush_tlbs,NULL ); }
Signature · 1 line
2.11.0
PATCH 43/65 x86/logdirty: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/mm/hap/hap.c | 6 +++--- xen/arch/x86/mm/shadow/common.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-)
xen/arch/x86/mm/hap/hap.c +3 -3
@@ -180,7 +180,7 @@ int hap_track_dirty_vram(struct domain *d,* NB: Domain that having device assigned should not set log_global. Because * there is no way to track the memory updating from device. */ -static int hap_enable_log_dirty (struct domain *d,bool_t log_global) +static int cf_check hap_enable_log_dirty(struct domain *d, bool log_global) {struct p2m_domain *p2m =p2m_get_hostp2m (d);
@@ -211,7 +211,7 @@ static int hap_enable_log_dirty(struct domain *d, bool_t log_global)return 0 ; } -static int hap_disable_log_dirty (struct domain *d) +static int cf_check hap_disable_log_dirty(struct domain *d) {paging_lock (d); d->arch.paging.mode &= ~PG_log_dirty;
@@ -228,7 +228,7 @@ static int hap_disable_log_dirty(struct domain *d)return 0 ; } -static void hap_clean_dirty_bitmap (struct domain *d) +static void cf_check hap_clean_dirty_bitmap(struct domain *d) {/* * Switch to log-dirty mode, either by setting l1e entries of P2M table to
xen/arch/x86/mm/shadow/common.c +6 -6
@@ -40,9 +40,9 @@DEFINE_PER_CPU (uint32_t,trace_shadow_path_flags); -static int sh_enable_log_dirty (struct domain *,bool log_global); -static int sh_disable_log_dirty (struct domain *); -static void sh_clean_dirty_bitmap (struct domain *); +static int cf_check sh_enable_log_dirty(struct domain *, bool log_global); +static int cf_check sh_disable_log_dirty(struct domain *); +static void cf_check sh_clean_dirty_bitmap(struct domain *);/* Set up the shadow-specific parts of a domain struct at start of day. * Called for every domain from arch_domain_create() */
@@ -3016,7 +3016,7 @@ static int shadow_test_disable(struct domain *d)/* Shadow specific code which is called in paging_log_dirty_enable(). * Return 0 if no problem found. */ -static int sh_enable_log_dirty (struct domain *d,bool log_global) +static int cf_check sh_enable_log_dirty(struct domain *d, bool log_global) {int ret;
@@ -3044,7 +3044,7 @@ static int sh_enable_log_dirty(struct domain *d, bool log_global) }/* shadow specfic code which is called in paging_log_dirty_disable() */ -static int sh_disable_log_dirty (struct domain *d) +static int cf_check sh_disable_log_dirty(struct domain *d) {int ret;
@@ -3058,7 +3058,7 @@ static int sh_disable_log_dirty(struct domain *d)/* This function is called when we CLEAN log dirty bitmap. See * paging_log_dirty_op() for details. */ -static void sh_clean_dirty_bitmap (struct domain *d) +static void cf_check sh_clean_dirty_bitmap(struct domain *d) {paging_lock (d);/* Need to revoke write access to the domain's pages again.
Signature · 1 line
2.11.0
PATCH 44/65 x86/shadow: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/mm/shadow/common.c | 11 +++--- xen/arch/x86/mm/shadow/hvm.c | 8 ++-- xen/arch/x86/mm/shadow/multi.c | 80 ++++++++++++++++++++-------------------- xen/arch/x86/mm/shadow/multi.h | 20 +++++----- xen/arch/x86/mm/shadow/private.h | 12 +++--- xen/arch/x86/mm/shadow/pv.c | 4 +- 6 files changed, 67 insertions(+), 68 deletions(-)
xen/arch/x86/mm/shadow/common.c +6 -5
@@ -1215,7 +1215,7 @@ void shadow_free(struct domain *d, mfn_t smfn)* This action is irreversible: the p2m mapping only ever grows. * That's OK because the p2m table only exists for translated domains, * and those domains can't ever turn off shadow mode. */ -static struct page_info * +static struct page_info *cf_checkshadow_alloc_p2m_page (struct domain *d) {struct page_info *pg;
@@ -1251,7 +1251,7 @@ shadow_alloc_p2m_page(struct domain *d)return pg; } -static void +static void cf_checkshadow_free_p2m_page (struct domain *d,struct page_info *pg) {struct domain *owner =page_get_owner (pg);
@@ -2290,7 +2290,8 @@ void shadow_prepare_page_type_change(struct domain *d, struct page_info *page,/* Reset the up-pointers of every L3 shadow to 0. * This is called when l3 shadows stop being pinnable, to clear out all * the list-head bits so the up-pointer field is properly inititalised. */ -static int sh_clear_up_pointer (struct vcpu *v,mfn_t smfn,mfn_t unused) +static int cf_check sh_clear_up_pointer( +struct vcpu *v,mfn_t smfn,mfn_t unused) {mfn_to_page (smfn)->up =0 ;return 0 ;
@@ -2490,7 +2491,7 @@ static void sh_update_paging_modes(struct vcpu *v) v->arch.paging.mode->update_cr3 (v,0 , false); } -void shadow_update_paging_modes (struct vcpu *v) +void cf_check shadow_update_paging_modes(struct vcpu *v) {paging_lock (v->domain);sh_update_paging_modes (v);
@@ -3075,7 +3076,7 @@ static bool flush_vcpu(const struct vcpu *v, const unsigned long *vcpu_bitmap) }/* Flush TLB of selected vCPUs. NULL for all. */ -bool shadow_flush_tlb (const unsigned long *vcpu_bitmap) +bool cf_check shadow_flush_tlb(const unsigned long *vcpu_bitmap) { static DEFINE_PER_CPU(cpumask_t, flush_cpumask);cpumask_t *mask = &this_cpu (flush_cpumask);
xen/arch/x86/mm/shadow/hvm.c +4 -4
@@ -797,9 +797,9 @@ sh_remove_all_shadows_and_parents(struct domain *d, mfn_t gmfn)* It means extra emulated writes and slows down removal of mappings. */ } -static void sh_unshadow_for_p2m_change (struct domain *d,unsigned long gfn, -l1_pgentry_t old,l1_pgentry_t new, -unsigned int level) +static void cf_check sh_unshadow_for_p2m_change( +struct domain *d,unsigned long gfn,l1_pgentry_t old,l1_pgentry_t new, +unsigned int level) {mfn_t omfn =l1e_get_mfn (old);unsigned int oflags =l1e_get_flags (old);
@@ -882,7 +882,7 @@ static void sh_unshadow_for_p2m_change(struct domain *d, unsigned long gfn, }#if (SHADOW_OPTIMIZATIONS &SHOPT_FAST_FAULT_PATH ) -static void +static void cf_checksh_write_p2m_entry_post (struct p2m_domain *p2m,unsigned int oflags) {struct domain *d = p2m->domain;
xen/arch/x86/mm/shadow/multi.c +39 -41
252 lines not on this page · raw message
xen/arch/x86/mm/shadow/multi.h +10 -10
@@ -59,10 +59,10 @@ extern voidSHADOW_INTERNAL_NAME (sh_unhook_64b_mappings,GUEST_LEVELS ) (struct domain *d, mfn_t sl4mfn, int user_only); -extern int +int cf_checkSHADOW_INTERNAL_NAME (sh_rm_write_access_from_l1 ,GUEST_LEVELS ) (struct domain *d,mfn_t sl1mfn,mfn_t readonly_mfn); -extern int +int cf_checkSHADOW_INTERNAL_NAME (sh_rm_mappings_from_l1 ,GUEST_LEVELS ) (struct domain *d,mfn_t sl1mfn,mfn_t target_mfn);
@@ -70,30 +70,30 @@ extern voidSHADOW_INTERNAL_NAME (sh_clear_shadow_entry,GUEST_LEVELS ) (struct domain *d, void *ep, mfn_t smfn); -extern int +int cf_checkSHADOW_INTERNAL_NAME (sh_remove_l1_shadow ,GUEST_LEVELS ) (struct domain *d,mfn_t sl2mfn,mfn_t sl1mfn); -extern int +int cf_checkSHADOW_INTERNAL_NAME (sh_remove_l2_shadow ,GUEST_LEVELS ) (struct domain *d,mfn_t sl3mfn,mfn_t sl2mfn); -extern int +int cf_checkSHADOW_INTERNAL_NAME (sh_remove_l3_shadow ,GUEST_LEVELS ) (struct domain *d,mfn_t sl4mfn,mfn_t sl3mfn);#if SHADOW_AUDIT &SHADOW_AUDIT_ENTRIES -int +int cf_checkSHADOW_INTERNAL_NAME (sh_audit_l1_table ,GUEST_LEVELS ) (struct vcpu *v,mfn_t sl1mfn,mfn_t x); -int +int cf_checkSHADOW_INTERNAL_NAME (sh_audit_fl1_table ,GUEST_LEVELS ) (struct vcpu *v,mfn_t sl1mfn,mfn_t x); -int +int cf_checkSHADOW_INTERNAL_NAME (sh_audit_l2_table ,GUEST_LEVELS ) (struct vcpu *v,mfn_t sl2mfn,mfn_t x); -int +int cf_checkSHADOW_INTERNAL_NAME (sh_audit_l3_table ,GUEST_LEVELS ) (struct vcpu *v,mfn_t sl3mfn,mfn_t x); -int +int cf_checkSHADOW_INTERNAL_NAME (sh_audit_l4_table ,GUEST_LEVELS ) (struct vcpu *v,mfn_t sl4mfn,mfn_t x);#endif
xen/arch/x86/mm/shadow/private.h +6 -6
@@ -420,15 +420,15 @@ static inline int sh_remove_write_access(struct domain *d, mfn_t readonly_mfn,#endif /* Functions that atomically write PV guest PT entries */ -void sh_write_guest_entry (struct vcpu *v,intpte_t *p,intpte_t new, -mfn_t gmfn); -intpte_t sh_cmpxchg_guest_entry (struct vcpu *v,intpte_t *p,intpte_t old, -intpte_t new,mfn_t gmfn); +void cf_check sh_write_guest_entry( +struct vcpu *v,intpte_t *p,intpte_t new,mfn_t gmfn); +intpte_t cf_check sh_cmpxchg_guest_entry( +struct vcpu *v,intpte_t *p,intpte_t old,intpte_t new,mfn_t gmfn);/* Update all the things that are derived from the guest's CR0/CR3/CR4. * Called to initialize paging structures if the paging mode * has changed, and when bringing up a VCPU for the first time. */ -void shadow_update_paging_modes (struct vcpu *v); +void cf_check shadow_update_paging_modes(struct vcpu *v);/* Unhook the non-Xen mappings in this top-level shadow mfn. * With user_only == 1, unhooks only the user-mode mappings. */
@@ -922,7 +922,7 @@ static inline int sh_check_page_has_no_refs(struct page_info *page) }/* Flush the TLB of the selected vCPUs. */ -bool shadow_flush_tlb (const unsigned long *vcpu_bitmap); +bool cf_check shadow_flush_tlb(const unsigned long *vcpu_bitmap);#endif /* _XEN_SHADOW_PRIVATE_H */
xen/arch/x86/mm/shadow/pv.c +2 -2
@@ -28,7 +28,7 @@* Write a new value into the guest pagetable, and update the shadows * appropriately. */ -void +void cf_checksh_write_guest_entry (struct vcpu *v,intpte_t *p,intpte_t new,mfn_t gmfn) {paging_lock (v->domain);
@@ -42,7 +42,7 @@ sh_write_guest_entry(struct vcpu *v, intpte_t *p, intpte_t new, mfn_t gmfn)* appropriately. Returns the previous entry found, which the caller is * expected to check to see if the cmpxchg was successful. */ -intpte_t +intpte_t cf_checksh_cmpxchg_guest_entry (struct vcpu *v,intpte_t *p,intpte_t old,intpte_t new,mfn_t gmfn) {
Signature · 1 line
2.11.0
PATCH 45/65 x86/hap: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/mm/hap/guest_walk.c | 4 ++-- xen/arch/x86/mm/hap/hap.c | 21 +++++++++++---------- xen/arch/x86/mm/hap/private.h | 30 ++++++++++++------------------ 3 files changed, 25 insertions(+), 30 deletions(-)
xen/arch/x86/mm/hap/guest_walk.c +2 -2
@@ -36,14 +36,14 @@#include <asm/guest_pt.h> #include <asm/p2m.h> -unsigned long hap_gva_to_gfn (GUEST_PAGING_LEVELS )( +unsigned long cf_check hap_gva_to_gfn (GUEST_PAGING_LEVELS )(struct vcpu *v,struct p2m_domain *p2m,unsigned long gva,uint32_t *pfec) {unsigned long cr3 = v->arch.hvm.guest_cr[3 ];return hap_p2m_ga_to_gfn (GUEST_PAGING_LEVELS )(v, p2m, cr3, gva, pfec,NULL ); } -unsigned long hap_p2m_ga_to_gfn (GUEST_PAGING_LEVELS )( +unsigned long cf_check hap_p2m_ga_to_gfn (GUEST_PAGING_LEVELS )(struct vcpu *v,struct p2m_domain *p2m,unsigned long cr3,paddr_t ga,uint32_t *pfec,unsigned int *page_order) {
xen/arch/x86/mm/hap/hap.c +11 -10
@@ -268,7 +268,7 @@ static void hap_free(struct domain *d, mfn_t mfn)page_list_add_tail (pg, &d->arch.paging.hap.freelist); } -static struct page_info *hap_alloc_p2m_page (struct domain *d) +static struct page_info *cf_check hap_alloc_p2m_page(struct domain *d) {struct page_info *pg;
@@ -294,7 +294,7 @@ static struct page_info *hap_alloc_p2m_page(struct domain *d)return pg; } -static void hap_free_p2m_page (struct domain *d,struct page_info *pg) +static void cf_check hap_free_p2m_page(struct domain *d, struct page_info *pg) {struct domain *owner =page_get_owner (pg);
@@ -662,8 +662,8 @@ void hap_vcpu_init(struct vcpu *v)* HAP guests can handle page faults (in the guest page tables) without * needing any action from Xen, so we should not be intercepting them. */ -static int hap_page_fault (struct vcpu *v,unsigned long va, -struct cpu_user_regs *regs) +static int cf_check hap_page_fault( +struct vcpu *v,unsigned long va,struct cpu_user_regs *regs) {struct domain *d = v->domain;
@@ -677,7 +677,7 @@ static int hap_page_fault(struct vcpu *v, unsigned long va,* should not be intercepting it. However, we need to correctly handle * getting here from instruction emulation. */ -static bool_t hap_invlpg (struct vcpu *v,unsigned long linear) +static bool cf_check hap_invlpg(struct vcpu *v, unsigned long linear) {/* * Emulate INVLPGA:
@@ -690,7 +690,8 @@ static bool_t hap_invlpg(struct vcpu *v, unsigned long linear)return 1 ; } -static void hap_update_cr3 (struct vcpu *v,int do_locking,bool noflush) +static void cf_check hap_update_cr3( +struct vcpu *v,int do_locking,bool noflush) { v->arch.hvm.hw_cr[3 ] = v->arch.hvm.guest_cr[3 ];hvm_update_guest_cr3 (v, noflush);
@@ -702,7 +703,7 @@ static bool flush_vcpu(const struct vcpu *v, const unsigned long *vcpu_bitmap) }/* Flush TLB of selected vCPUs. NULL for all. */ -static bool flush_tlb (const unsigned long *vcpu_bitmap) +static bool cf_check flush_tlb(const unsigned long *vcpu_bitmap) { static DEFINE_PER_CPU(cpumask_t, flush_cpumask);cpumask_t *mask = &this_cpu (flush_cpumask);
@@ -747,7 +748,7 @@ hap_paging_get_mode(struct vcpu *v) &hap_paging_protected_mode); } -static void hap_update_paging_modes (struct vcpu *v) +static void cf_check hap_update_paging_modes(struct vcpu *v) {struct domain *d = v->domain;unsigned long cr3_gfn = v->arch.hvm.guest_cr[3 ] >>PAGE_SHIFT ;
@@ -791,13 +792,13 @@ void hap_p2m_init(struct p2m_domain *p2m) p2m->write_p2m_entry_post = hap_write_p2m_entry_post; } -static unsigned long hap_gva_to_gfn_real_mode ( +static unsigned long cf_check hap_gva_to_gfn_real_mode (struct vcpu *v,struct p2m_domain *p2m,unsigned long gva,uint32_t *pfec) {return ((paddr_t )gva >>PAGE_SHIFT ); } -static unsigned long hap_p2m_ga_to_gfn_real_mode ( +static unsigned long cf_check hap_p2m_ga_to_gfn_real_mode (struct vcpu *v,struct p2m_domain *p2m,unsigned long cr3,paddr_t ga,uint32_t *pfec,unsigned int *page_order) {
xen/arch/x86/mm/hap/private.h +12 -18
@@ -24,27 +24,21 @@/********************************************/ /* GUEST TRANSLATION FUNCS */ /********************************************/ -unsigned long hap_gva_to_gfn_2_levels (struct vcpu *v, -struct p2m_domain *p2m, -unsigned long gva, -uint32_t *pfec); -unsigned long hap_gva_to_gfn_3_levels (struct vcpu *v, -struct p2m_domain *p2m, -unsigned long gva, -uint32_t *pfec); -unsigned long hap_gva_to_gfn_4_levels (struct vcpu *v, -struct p2m_domain *p2m, -unsigned long gva, -uint32_t *pfec); +unsigned long cf_check hap_gva_to_gfn_2_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long gva,uint32_t *pfec); +unsigned long cf_check hap_gva_to_gfn_3_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long gva,uint32_t *pfec); +unsigned long cf_check hap_gva_to_gfn_4_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long gva,uint32_t *pfec); -unsigned long hap_p2m_ga_to_gfn_2_levels (struct vcpu *v, -struct p2m_domain *p2m,unsigned long cr3, +unsigned long cf_check hap_p2m_ga_to_gfn_2_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long cr3,paddr_t ga,uint32_t *pfec,unsigned int *page_order); -unsigned long hap_p2m_ga_to_gfn_3_levels (struct vcpu *v, -struct p2m_domain *p2m,unsigned long cr3, +unsigned long cf_check hap_p2m_ga_to_gfn_3_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long cr3,paddr_t ga,uint32_t *pfec,unsigned int *page_order); -unsigned long hap_p2m_ga_to_gfn_4_levels (struct vcpu *v, -struct p2m_domain *p2m,unsigned long cr3, +unsigned long cf_check hap_p2m_ga_to_gfn_4_levels ( +struct vcpu *v,struct p2m_domain *p2m,unsigned long cr3,paddr_t ga,uint32_t *pfec,unsigned int *page_order);#endif /* __HAP_PRIVATE_H__ */
Signature · 1 line
2.11.0
PATCH 46/65 x86/p2m: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/mm/hap/hap.c | 2 +- xen/arch/x86/mm/hap/nested_hap.c | 2 +- xen/arch/x86/mm/p2m-ept.c | 32 +++++++++++++++----------------- xen/arch/x86/mm/p2m-pt.c | 19 +++++++++---------- xen/include/asm-x86/p2m.h | 4 ++-- 5 files changed, 28 insertions(+), 31 deletions(-)
xen/arch/x86/mm/hap/hap.c +1 -1
@@ -778,7 +778,7 @@ static void cf_check hap_update_paging_modes(struct vcpu *v)put_gfn (d, cr3_gfn); } -static void +static void cf_checkhap_write_p2m_entry_post (struct p2m_domain *p2m,unsigned int oflags) {struct domain *d = p2m->domain;
xen/arch/x86/mm/hap/nested_hap.c +1 -1
@@ -71,7 +71,7 @@/* NESTED VIRT P2M FUNCTIONS */ /********************************************/ -void +void cf_checknestedp2m_write_p2m_entry_post (struct p2m_domain *p2m,unsigned int oflags) {if ( oflags & _PAGE_PRESENT )
xen/arch/x86/mm/p2m-ept.c +15 -17
@@ -625,7 +625,7 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn,* - zero if no adjustment was done, * - a positive value if at least one adjustment was done. */ -static int resolve_misconfig (struct p2m_domain *p2m,unsigned long gfn) +static int cf_check resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn) {struct ept_data *ept = &p2m->ept;unsigned int level = ept->wl;
@@ -794,7 +794,7 @@ bool_t ept_handle_misconfig(uint64_t gpa)* * Returns: 0 for success, -errno for failure */ -static int +static int cf_checkept_set_entry (struct p2m_domain *p2m,gfn_t gfn_,mfn_t mfn,unsigned int order,p2m_type_t p2mt,p2m_access_t p2ma,int sve)
@@ -1003,10 +1003,9 @@ ept_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, }/* Read ept p2m entries */ -static mfn_t ept_get_entry (struct p2m_domain *p2m, -gfn_t gfn_,p2m_type_t *t,p2m_access_t * a, -p2m_query_t q,unsigned int *page_order, -bool_t *sve) +static mfn_t cf_check ept_get_entry( +struct p2m_domain *p2m,gfn_t gfn_,p2m_type_t *t,p2m_access_t * a, +p2m_query_t q,unsigned int *page_order,bool_t *sve) {ept_entry_t *table =map_domain_page (pagetable_get_mfn (p2m_get_pagetable (p2m)));
@@ -1166,8 +1165,8 @@ void ept_walk_table(struct domain *d, unsigned long gfn)return ; } -static void ept_change_entry_type_global (struct p2m_domain *p2m, -p2m_type_t ot,p2m_type_t nt) +static void cf_check ept_change_entry_type_global( +struct p2m_domain *p2m,p2m_type_t ot,p2m_type_t nt) {unsigned long mfn = p2m->ept.mfn;
@@ -1178,10 +1177,9 @@ static void ept_change_entry_type_global(struct p2m_domain *p2m,ept_sync_domain (p2m); } -static int ept_change_entry_type_range (struct p2m_domain *p2m, -p2m_type_t ot,p2m_type_t nt, -unsigned long first_gfn, -unsigned long last_gfn) +static int cf_check ept_change_entry_type_range( +struct p2m_domain *p2m,p2m_type_t ot,p2m_type_t nt, +unsigned long first_gfn,unsigned long last_gfn) {unsigned int i, wl = p2m->ept.wl;unsigned long mask = (1 <<EPT_TABLE_ORDER ) -1 ;
@@ -1225,7 +1223,7 @@ static int ept_change_entry_type_range(struct p2m_domain *p2m,return rc <0 ? rc :0 ; } -static void ept_memory_type_changed (struct p2m_domain *p2m) +static void cf_check ept_memory_type_changed(struct p2m_domain *p2m) {unsigned long mfn = p2m->ept.mfn;
@@ -1284,7 +1282,7 @@ void ept_sync_domain(struct p2m_domain *p2m)ept_sync_domain_mask (p2m, d->dirty_cpumask); } -static void ept_tlb_flush (struct p2m_domain *p2m) +static void cf_check ept_tlb_flush(struct p2m_domain *p2m) {ept_sync_domain_mask (p2m, p2m->domain->dirty_cpumask); }
@@ -1347,7 +1345,7 @@ static void ept_disable_pml(struct p2m_domain *p2m)vmx_domain_update_eptp (p2m->domain); } -static void ept_enable_hardware_log_dirty (struct p2m_domain *p2m) +static void cf_check ept_enable_hardware_log_dirty(struct p2m_domain *p2m) {struct p2m_domain *hostp2m =p2m_get_hostp2m (p2m->domain);
@@ -1356,7 +1354,7 @@ static void ept_enable_hardware_log_dirty(struct p2m_domain *p2m)p2m_unlock (hostp2m); } -static void ept_disable_hardware_log_dirty (struct p2m_domain *p2m) +static void cf_check ept_disable_hardware_log_dirty(struct p2m_domain *p2m) {struct p2m_domain *hostp2m =p2m_get_hostp2m (p2m->domain);
@@ -1365,7 +1363,7 @@ static void ept_disable_hardware_log_dirty(struct p2m_domain *p2m)p2m_unlock (hostp2m); } -static void ept_flush_pml_buffers (struct p2m_domain *p2m) +static void cf_check ept_flush_pml_buffers(struct p2m_domain *p2m) {/* Domain must have been paused */ ASSERT (atomic_read (&p2m->domain->pause_count));
xen/arch/x86/mm/p2m-pt.c +9 -10
@@ -399,7 +399,7 @@ static int p2m_pt_set_recalc_range(struct p2m_domain *p2m,* GFN. Propagate the re-calculation flag down to the next page table level * for entries not involved in the translation of the given GFN. */ -static int do_recalc (struct p2m_domain *p2m,unsigned long gfn) +static int cf_check do_recalc(struct p2m_domain *p2m, unsigned long gfn) {void *table;unsigned long gfn_remainder = gfn;
@@ -573,7 +573,7 @@ static void check_entry(mfn_t mfn, p2m_type_t new, p2m_type_t old, }/* Returns: 0 for success, -errno for failure */ -static int +static int cf_checkp2m_pt_set_entry (struct p2m_domain *p2m,gfn_t gfn_,mfn_t mfn,unsigned int page_order,p2m_type_t p2mt,p2m_access_t p2ma,int sve)
@@ -774,7 +774,7 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn,return rc; } -static mfn_t +static mfn_t cf_checkp2m_pt_get_entry (struct p2m_domain *p2m,gfn_t gfn_,p2m_type_t *t,p2m_access_t *a,p2m_query_t q,unsigned int *page_order,bool_t *sve)
@@ -943,8 +943,8 @@ p2m_pt_get_entry(struct p2m_domain *p2m, gfn_t gfn_,return (p2m_is_valid (*t) ||p2m_is_any_ram (*t)) ? mfn :INVALID_MFN ; } -static void p2m_pt_change_entry_type_global (struct p2m_domain *p2m, -p2m_type_t ot,p2m_type_t nt) +static void cf_check p2m_pt_change_entry_type_global( +struct p2m_domain *p2m,p2m_type_t ot,p2m_type_t nt) {l1_pgentry_t *tab;unsigned long gfn =0 ;
@@ -983,10 +983,9 @@ static void p2m_pt_change_entry_type_global(struct p2m_domain *p2m,guest_flush_tlb_mask (d, d->dirty_cpumask); } -static int p2m_pt_change_entry_type_range (struct p2m_domain *p2m, -p2m_type_t ot,p2m_type_t nt, -unsigned long first_gfn, -unsigned long last_gfn) +static int cf_check p2m_pt_change_entry_type_range( +struct p2m_domain *p2m,p2m_type_t ot,p2m_type_t nt, +unsigned long first_gfn,unsigned long last_gfn) {unsigned long mask = (1 <<PAGETABLE_ORDER ) -1 ;unsigned int i;
@@ -1025,7 +1024,7 @@ static int p2m_pt_change_entry_type_range(struct p2m_domain *p2m, }#if P2M_AUDIT -static long p2m_pt_audit_p2m (struct p2m_domain *p2m) +static long cf_check p2m_pt_audit_p2m (struct p2m_domain *p2m) {unsigned long entry_count =0 , pmbad =0 ;unsigned long mfn, gfn, m2pfn;
xen/include/asm-x86/p2m.h +2 -2
@@ -820,8 +820,8 @@ void np2m_flush_base(struct vcpu *v, unsigned long np2m_base);void hap_p2m_init (struct p2m_domain *p2m);void shadow_p2m_init (struct p2m_domain *p2m); -void nestedp2m_write_p2m_entry_post (struct p2m_domain *p2m, -unsigned int oflags); +void cf_check nestedp2m_write_p2m_entry_post( +struct p2m_domain *p2m,unsigned int oflags);/* * Alternate p2m: shadow p2m tables used for alternate memory views
Signature · 1 line
2.11.0
PATCH 47/65 x86/irq: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/hpet.c | 11 ++++++----- xen/arch/x86/i8259.c | 10 +++++----- xen/arch/x86/io_apic.c | 24 ++++++++++++------------ xen/arch/x86/irq.c | 6 +++--- xen/arch/x86/msi.c | 14 +++++++------- xen/common/irq.c | 6 +++--- xen/drivers/passthrough/amd/iommu_init.c | 15 ++++++++------- xen/drivers/passthrough/vtd/iommu.c | 13 +++++++------ xen/include/asm-x86/irq.h | 8 ++++---- xen/include/asm-x86/msi.h | 8 ++++---- xen/include/xen/irq.h | 6 +++--- 11 files changed, 62 insertions(+), 59 deletions(-)
xen/arch/x86/hpet.c +6 -5
@@ -256,7 +256,7 @@ static void cf_check hpet_interrupt_handler( ch->event_handler (ch); } -static void hpet_msi_unmask (struct irq_desc *desc) +static void cf_check hpet_msi_unmask(struct irq_desc *desc) {u32 cfg;struct hpet_event_channel *ch = desc->action->dev_id;
@@ -267,7 +267,7 @@ static void hpet_msi_unmask(struct irq_desc *desc) ch->msi.msi_attrib.host_masked =0 ; } -static void hpet_msi_mask (struct irq_desc *desc) +static void cf_check hpet_msi_mask(struct irq_desc *desc) {u32 cfg;struct hpet_event_channel *ch = desc->action->dev_id;
@@ -296,7 +296,7 @@ static int hpet_msi_write(struct hpet_event_channel *ch, struct msi_msg *msg)return 0 ; } -static unsigned int hpet_msi_startup (struct irq_desc *desc) +static unsigned int cf_check hpet_msi_startup(struct irq_desc *desc) {hpet_msi_unmask (desc);return 0 ;
@@ -304,14 +304,15 @@ static unsigned int hpet_msi_startup(struct irq_desc *desc)#define hpet_msi_shutdown hpet_msi_mask -static void hpet_msi_ack (struct irq_desc *desc) +static void cf_check hpet_msi_ack(struct irq_desc *desc) {irq_complete_move (desc);move_native_irq (desc);ack_APIC_irq (); } -static void hpet_msi_set_affinity (struct irq_desc *desc,const cpumask_t *mask) +static void cf_check hpet_msi_set_affinity( +struct irq_desc *desc,const cpumask_t *mask) {struct hpet_event_channel *ch = desc->action->dev_id;struct msi_msg msg = ch->msi.msg;
xen/arch/x86/i8259.c +5 -5
@@ -40,18 +40,18 @@ bool bogus_8259A_irq(unsigned int irq)return _mask_and_ack_8259A_irq (irq); } -static void mask_and_ack_8259A_irq (struct irq_desc *desc) +static void cf_check mask_and_ack_8259A_irq(struct irq_desc *desc) {_mask_and_ack_8259A_irq (desc->irq); } -static unsigned int startup_8259A_irq (struct irq_desc *desc) +static unsigned int cf_check startup_8259A_irq(struct irq_desc *desc) {enable_8259A_irq (desc);return 0 ;/* never anything pending */ } -static void end_8259A_irq (struct irq_desc *desc,u8 vector) +static void cf_check end_8259A_irq(struct irq_desc *desc, u8 vector) {if (!(desc->status & (IRQ_DISABLED |IRQ_INPROGRESS )))enable_8259A_irq (desc);
@@ -108,12 +108,12 @@ static void _disable_8259A_irq(unsigned int irq)spin_unlock_irqrestore (&i8259A_lock, flags); } -void disable_8259A_irq (struct irq_desc *desc) +void cf_check disable_8259A_irq(struct irq_desc *desc) {_disable_8259A_irq (desc->irq); } -void enable_8259A_irq (struct irq_desc *desc) +void cf_check enable_8259A_irq(struct irq_desc *desc) {unsigned int mask = ~(1 << desc->irq);unsigned long flags;
xen/arch/x86/io_apic.c +12 -12
@@ -473,7 +473,7 @@ static void __level_IO_APIC_irq (unsigned int irq)modify_IO_APIC_irq (irq,IO_APIC_REDIR_LEVEL_TRIGGER ,0 ); } -static void mask_IO_APIC_irq (struct irq_desc *desc) +static void cf_check mask_IO_APIC_irq(struct irq_desc *desc) {unsigned long flags;
@@ -482,7 +482,7 @@ static void mask_IO_APIC_irq(struct irq_desc *desc)spin_unlock_irqrestore (&ioapic_lock, flags); } -static void unmask_IO_APIC_irq (struct irq_desc *desc) +static void cf_check unmask_IO_APIC_irq(struct irq_desc *desc) {unsigned long flags;
@@ -567,7 +567,7 @@ static void clear_IO_APIC (void) } } -static void +static void cf_checkset_ioapic_affinity_irq (struct irq_desc *desc,const cpumask_t *mask) {unsigned int dest;
@@ -1547,7 +1547,7 @@ static int __init timer_irq_works(void)* This is not complete - we should be able to fake * an edge even if it isn't on the 8259A... */ -static unsigned int startup_edge_ioapic_irq (struct irq_desc *desc) +static unsigned int cf_check startup_edge_ioapic_irq(struct irq_desc *desc) {int was_pending =0 ;unsigned long flags;
@@ -1569,7 +1569,7 @@ static unsigned int startup_edge_ioapic_irq(struct irq_desc *desc)* interrupt for real. This prevents IRQ storms from unhandled * devices. */ -static void ack_edge_ioapic_irq (struct irq_desc *desc) +static void cf_check ack_edge_ioapic_irq(struct irq_desc *desc) {irq_complete_move (desc);move_native_irq (desc);
@@ -1594,7 +1594,7 @@ static void ack_edge_ioapic_irq(struct irq_desc *desc)* generic IRQ layer and by the fact that an unacked local * APIC does not accept IRQs. */ -static unsigned int startup_level_ioapic_irq (struct irq_desc *desc) +static unsigned int cf_check startup_level_ioapic_irq(struct irq_desc *desc) {unmask_IO_APIC_irq (desc);
@@ -1652,7 +1652,7 @@ static bool io_apic_level_ack_pending(unsigned int irq)return 0 ; } -static void mask_and_ack_level_ioapic_irq (struct irq_desc *desc) +static void cf_check mask_and_ack_level_ioapic_irq(struct irq_desc *desc) {unsigned long v;int i;
@@ -1702,7 +1702,7 @@ static void mask_and_ack_level_ioapic_irq(struct irq_desc *desc) } } -static void end_level_ioapic_irq_old (struct irq_desc *desc,u8 vector) +static void cf_check end_level_ioapic_irq_old(struct irq_desc *desc, u8 vector) {if ( directed_eoi_enabled ) {
@@ -1723,7 +1723,7 @@ static void end_level_ioapic_irq_old(struct irq_desc *desc, u8 vector)unmask_IO_APIC_irq (desc); } -static void end_level_ioapic_irq_new (struct irq_desc *desc,u8 vector) +static void cf_check end_level_ioapic_irq_new(struct irq_desc *desc, u8 vector) {/* * It appears there is an erratum which affects at least version 0x11
@@ -1807,7 +1807,7 @@ static inline void init_IO_APIC_traps(void)make_8259A_irq (irq); } -static void enable_lapic_irq (struct irq_desc *desc) +static void cf_check enable_lapic_irq(struct irq_desc *desc) {unsigned long v;
@@ -1815,7 +1815,7 @@ static void enable_lapic_irq(struct irq_desc *desc)apic_write (APIC_LVT0 , v & ~APIC_LVT_MASKED ); } -static void disable_lapic_irq (struct irq_desc *desc) +static void cf_check disable_lapic_irq(struct irq_desc *desc) {unsigned long v;
@@ -1823,7 +1823,7 @@ static void disable_lapic_irq(struct irq_desc *desc)apic_write (APIC_LVT0 , v |APIC_LVT_MASKED ); } -static void ack_lapic_irq (struct irq_desc *desc) +static void cf_check ack_lapic_irq(struct irq_desc *desc) {ack_APIC_irq (); }
xen/arch/x86/irq.c +3 -3
@@ -468,7 +468,7 @@ int __init init_irq_data(void)return 0 ; } -static void ack_none (struct irq_desc *desc) +static void cf_check ack_none(struct irq_desc *desc) {ack_bad_irq (desc->irq); }
@@ -832,7 +832,7 @@ static void send_cleanup_vector(struct irq_desc *desc) desc->arch.move_in_progress =0 ; } -void irq_complete_move (struct irq_desc *desc) +void cf_check irq_complete_move(struct irq_desc *desc) {unsigned vector, me;
@@ -1086,7 +1086,7 @@ bool cpu_has_pending_apic_eoi(void)return pending_eoi_sp (this_cpu (pending_eoi)) !=0 ; } -void end_nonmaskable_irq (struct irq_desc *desc,uint8_t vector) +void cf_check end_nonmaskable_irq(struct irq_desc *desc, uint8_t vector) {struct pending_eoi *peoi =this_cpu (pending_eoi);unsigned int sp =pending_eoi_sp (peoi);
xen/arch/x86/msi.c +7 -7
@@ -241,7 +241,7 @@ static int write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)return 0 ; } -void set_msi_affinity (struct irq_desc *desc,const cpumask_t *mask) +void cf_check set_msi_affinity(struct irq_desc *desc, const cpumask_t *mask) {struct msi_msg msg;unsigned int dest;
@@ -416,14 +416,14 @@ static int msi_get_mask_bit(const struct msi_desc *entry)return -1 ; } -void mask_msi_irq (struct irq_desc *desc) +void cf_check mask_msi_irq(struct irq_desc *desc) {if (unlikely (!msi_set_mask_bit (desc,1 , desc->msi_desc->msi_attrib.guest_masked)) )BUG_ON (!(desc->status &IRQ_DISABLED )); } -void unmask_msi_irq (struct irq_desc *desc) +void cf_check unmask_msi_irq(struct irq_desc *desc) {if (unlikely (!msi_set_mask_bit (desc,0 , desc->msi_desc->msi_attrib.guest_masked)) )
@@ -435,26 +435,26 @@ void guest_mask_msi_irq(struct irq_desc *desc, bool mask)msi_set_mask_bit (desc, desc->msi_desc->msi_attrib.host_masked, mask); } -static unsigned int startup_msi_irq (struct irq_desc *desc) +static unsigned int cf_check startup_msi_irq(struct irq_desc *desc) {if (unlikely (!msi_set_mask_bit (desc,0 , !!(desc->status &IRQ_GUEST ))) )WARN ();return 0 ; } -static void shutdown_msi_irq (struct irq_desc *desc) +static void cf_check shutdown_msi_irq(struct irq_desc *desc) {if (unlikely (!msi_set_mask_bit (desc,1 ,1 )) )BUG_ON (!(desc->status &IRQ_DISABLED )); } -void ack_nonmaskable_msi_irq (struct irq_desc *desc) +void cf_check ack_nonmaskable_msi_irq(struct irq_desc *desc) {irq_complete_move (desc);move_native_irq (desc); } -static void ack_maskable_msi_irq (struct irq_desc *desc) +static void cf_check ack_maskable_msi_irq(struct irq_desc *desc) {ack_nonmaskable_msi_irq (desc);ack_APIC_irq ();/* ACKTYPE_NONE */
xen/common/irq.c +3 -3
@@ -27,15 +27,15 @@ int init_one_irq_desc(struct irq_desc *desc)return err; } -void no_action (int cpl,void *dev_id,struct cpu_user_regs *regs) +void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs) { } -void irq_actor_none (struct irq_desc *desc) +void cf_check irq_actor_none(struct irq_desc *desc) { } -unsigned int irq_startup_none (struct irq_desc *desc) +unsigned int cf_check irq_startup_none(struct irq_desc *desc) {return 0 ; }
xen/drivers/passthrough/amd/iommu_init.c +8 -7
@@ -410,7 +410,7 @@ static void amd_iommu_msi_enable(struct amd_iommu *iommu, int flag) PCI_FUNC(iommu->bdf), iommu->msi.msi_attrib.pos, flag); } -static void iommu_msi_unmask (struct irq_desc *desc) +static void cf_check iommu_msi_unmask(struct irq_desc *desc) {unsigned long flags;struct amd_iommu *iommu = desc->action->dev_id;
@@ -421,7 +421,7 @@ static void iommu_msi_unmask(struct irq_desc *desc) iommu->msi.msi_attrib.host_masked =0 ; } -static void iommu_msi_mask (struct irq_desc *desc) +static void cf_check iommu_msi_mask(struct irq_desc *desc) {unsigned long flags;struct amd_iommu *iommu = desc->action->dev_id;
@@ -434,13 +434,13 @@ static void iommu_msi_mask(struct irq_desc *desc) iommu->msi.msi_attrib.host_masked =1 ; } -static unsigned int iommu_msi_startup (struct irq_desc *desc) +static unsigned int cf_check iommu_msi_startup(struct irq_desc *desc) {iommu_msi_unmask (desc);return 0 ; } -static void iommu_msi_end (struct irq_desc *desc,u8 vector) +static void cf_check iommu_msi_end(struct irq_desc *desc, u8 vector) {iommu_msi_unmask (desc);end_nonmaskable_irq (desc, vector);
@@ -458,14 +458,14 @@ static hw_irq_controller iommu_msi_type = { .set_affinity = set_msi_affinity, }; -static unsigned int iommu_maskable_msi_startup (struct irq_desc *desc) +static unsigned int cf_check iommu_maskable_msi_startup(struct irq_desc *desc) {iommu_msi_unmask (desc);unmask_msi_irq (desc);return 0 ; } -static void iommu_maskable_msi_shutdown (struct irq_desc *desc) +static void cf_check iommu_maskable_msi_shutdown(struct irq_desc *desc) {mask_msi_irq (desc);iommu_msi_mask (desc);
@@ -489,7 +489,8 @@ static hw_irq_controller iommu_maskable_msi_type = { .set_affinity = set_msi_affinity, }; -static void set_x2apic_affinity (struct irq_desc *desc,const cpumask_t *mask) +static void cf_check set_x2apic_affinity( +struct irq_desc *desc,const cpumask_t *mask) {struct amd_iommu *iommu = desc->action->dev_id;unsigned int dest =set_desc_affinity (desc, mask);
xen/drivers/passthrough/vtd/iommu.c +7 -6
@@ -1096,7 +1096,7 @@ static void cf_check iommu_page_fault(tasklet_schedule (&vtd_fault_tasklet); } -static void dma_msi_unmask (struct irq_desc *desc) +static void cf_check dma_msi_unmask(struct irq_desc *desc) {struct vtd_iommu *iommu = desc->action->dev_id;unsigned long flags;
@@ -1111,7 +1111,7 @@ static void dma_msi_unmask(struct irq_desc *desc) iommu->msi.msi_attrib.host_masked =0 ; } -static void dma_msi_mask (struct irq_desc *desc) +static void cf_check dma_msi_mask(struct irq_desc *desc) {unsigned long flags;struct vtd_iommu *iommu = desc->action->dev_id;
@@ -1126,26 +1126,27 @@ static void dma_msi_mask(struct irq_desc *desc) iommu->msi.msi_attrib.host_masked =1 ; } -static unsigned int dma_msi_startup (struct irq_desc *desc) +static unsigned int cf_check dma_msi_startup(struct irq_desc *desc) {dma_msi_unmask (desc);return 0 ; } -static void dma_msi_ack (struct irq_desc *desc) +static void cf_check dma_msi_ack(struct irq_desc *desc) {irq_complete_move (desc);dma_msi_mask (desc);move_masked_irq (desc); } -static void dma_msi_end (struct irq_desc *desc,u8 vector) +static void cf_check dma_msi_end(struct irq_desc *desc, u8 vector) {dma_msi_unmask (desc);end_nonmaskable_irq (desc, vector); } -static void dma_msi_set_affinity (struct irq_desc *desc,const cpumask_t *mask) +static void cf_check dma_msi_set_affinity( +struct irq_desc *desc,const cpumask_t *mask) {struct msi_msg msg;unsigned int dest;
xen/include/asm-x86/irq.h +4 -4
@@ -111,8 +111,8 @@ void alloc_direct_apic_vector(void do_IRQ (struct cpu_user_regs *regs); -void disable_8259A_irq (struct irq_desc *); -void enable_8259A_irq (struct irq_desc *); +void cf_check disable_8259A_irq(struct irq_desc *); +void cf_check enable_8259A_irq(struct irq_desc *);int i8259A_irq_pending (unsigned int irq);void mask_8259A (void );void unmask_8259A (void );
@@ -173,7 +173,7 @@ int create_irq(nodeid_t node, bool grant_access);void destroy_irq (unsigned int irq);int assign_irq_vector (int irq,const cpumask_t *); -extern void irq_complete_move (struct irq_desc *); +void cf_check irq_complete_move(struct irq_desc *);extern struct irq_desc *irq_desc;
@@ -187,7 +187,7 @@ void move_masked_irq(struct irq_desc *);int bind_irq_vector (int irq,int vector,const cpumask_t *); -void end_nonmaskable_irq (struct irq_desc *,uint8_t vector); +void cf_check end_nonmaskable_irq(struct irq_desc *, uint8_t vector);void irq_set_affinity (struct irq_desc *,const cpumask_t *mask);int init_domain_irq_mapping (struct domain *);
xen/include/asm-x86/msi.h +4 -4
@@ -247,10 +247,10 @@ void early_msi_init(void);void msi_compose_msg (unsigned vector,const cpumask_t *mask,struct msi_msg *msg);void __msi_set_enable (u16 seg,u8 bus,u8 slot,u8 func,int pos,int enable); -void mask_msi_irq (struct irq_desc *); -void unmask_msi_irq (struct irq_desc *); +void cf_check mask_msi_irq(struct irq_desc *); +void cf_check unmask_msi_irq(struct irq_desc *);void guest_mask_msi_irq (struct irq_desc *,bool mask); -void ack_nonmaskable_msi_irq (struct irq_desc *); -void set_msi_affinity (struct irq_desc *,const cpumask_t *); +void cf_check ack_nonmaskable_msi_irq(struct irq_desc *); +void cf_check set_msi_affinity(struct irq_desc *, const cpumask_t *);#endif /* __ASM_MSI_H */
xen/include/xen/irq.h +3 -3
@@ -116,9 +116,9 @@ extern int request_irq(unsigned int irq, unsigned int irqflags, const char * devname, void *dev_id);extern hw_irq_controller no_irq_type; -extern void no_action (int cpl,void *dev_id,struct cpu_user_regs *regs); -extern unsigned int irq_startup_none (struct irq_desc *); -extern void irq_actor_none (struct irq_desc *); +void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs); +unsigned int cf_check irq_startup_none(struct irq_desc *); +void cf_check irq_actor_none(struct irq_desc *);#define irq_shutdown_none irq_actor_none#define irq_disable_none irq_actor_none#define irq_enable_none irq_actor_none
Signature · 1 line
2.11.0
PATCH 48/65 x86/aepi: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
I was very surprised when encountering this... AML and EFI are bad enough, but why on earth do we need yet another firmware provided arbitrary turning machine to be executing in Xen's context.
--- xen/drivers/acpi/apei/apei-base.c | 32 ++++++++++---------- xen/drivers/acpi/apei/apei-internal.h | 20 ++++++------ xen/drivers/acpi/apei/erst.c | 57 +++++++++++++++++------------------ 3 files changed, 54 insertions(+), 55 deletions(-)
xen/drivers/acpi/apei/apei-base.c +16 -16
@@ -80,8 +80,8 @@ int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val)return 0 ; } -int apei_exec_read_register (struct apei_exec_context *ctx, -struct acpi_whea_header *entry) +int cf_check apei_exec_read_register( +struct apei_exec_context *ctx,struct acpi_whea_header *entry) {int rc;u64 val =0 ;
@@ -94,8 +94,8 @@ int apei_exec_read_register(struct apei_exec_context *ctx,return 0 ; } -int apei_exec_read_register_value (struct apei_exec_context *ctx, -struct acpi_whea_header *entry) +int cf_check apei_exec_read_register_value( +struct apei_exec_context *ctx,struct acpi_whea_header *entry) {int rc;
@@ -126,14 +126,14 @@ int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val)return rc; } -int apei_exec_write_register (struct apei_exec_context *ctx, -struct acpi_whea_header *entry) +int cf_check apei_exec_write_register( +struct apei_exec_context *ctx,struct acpi_whea_header *entry) {return __apei_exec_write_register (entry, ctx->value); } -int apei_exec_write_register_value (struct apei_exec_context *ctx, -struct acpi_whea_header *entry) +int cf_check apei_exec_write_register_value( +struct apei_exec_context *ctx,struct acpi_whea_header *entry) {int rc;
@@ -143,8 +143,8 @@ int apei_exec_write_register_value(struct apei_exec_context *ctx,return rc; } -int apei_exec_noop (struct apei_exec_context *ctx, -struct acpi_whea_header *entry) +int cf_check apei_exec_noop( +struct apei_exec_context *ctx,struct acpi_whea_header *entry) {return 0 ; }
@@ -230,9 +230,9 @@ static int __init apei_exec_for_each_entry(struct apei_exec_context *ctx,return 0 ; } -static int __init pre_map_gar_callback (struct apei_exec_context *ctx, -struct acpi_whea_header *entry, -void *data) +static int __init cf_check pre_map_gar_callback( +struct apei_exec_context *ctx,struct acpi_whea_header *entry, +void *data) {u8 ins = entry->instruction;
@@ -259,9 +259,9 @@ int __init apei_exec_pre_map_gars(struct apei_exec_context *ctx)return rc; } -static int __init post_unmap_gar_callback (struct apei_exec_context *ctx, -struct acpi_whea_header *entry, -void *data) +static int __init cf_check post_unmap_gar_callback( +struct apei_exec_context *ctx,struct acpi_whea_header *entry, +void *data) {u8 ins = entry->instruction;
xen/drivers/acpi/apei/apei-internal.h +10 -10
@@ -68,16 +68,16 @@ static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 actioint __apei_exec_read_register (struct acpi_whea_header *entry,u64 *val);int __apei_exec_write_register (struct acpi_whea_header *entry,u64 val); -int apei_exec_read_register (struct apei_exec_context *ctx, -struct acpi_whea_header *entry); -int apei_exec_read_register_value (struct apei_exec_context *ctx, -struct acpi_whea_header *entry); -int apei_exec_write_register (struct apei_exec_context *ctx, -struct acpi_whea_header *entry); -int apei_exec_write_register_value (struct apei_exec_context *ctx, -struct acpi_whea_header *entry); -int apei_exec_noop (struct apei_exec_context *ctx, -struct acpi_whea_header *entry); +int cf_check apei_exec_read_register( +struct apei_exec_context *ctx,struct acpi_whea_header *entry); +int cf_check apei_exec_read_register_value( +struct apei_exec_context *ctx,struct acpi_whea_header *entry); +int cf_check apei_exec_write_register( +struct apei_exec_context *ctx,struct acpi_whea_header *entry); +int cf_check apei_exec_write_register_value( +struct apei_exec_context *ctx,struct acpi_whea_header *entry); +int cf_check apei_exec_noop( +struct apei_exec_context *ctx,struct acpi_whea_header *entry);int apei_exec_pre_map_gars (struct apei_exec_context *ctx);int apei_exec_post_unmap_gars (struct apei_exec_context *ctx);
xen/drivers/acpi/apei/erst.c +28 -29
128 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 48/65] x86/aepi: Annotate fnptr targets
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>
Nit: In the title I think you mean "x86/apei:".
Jan
PATCH 49/65 x86/psr: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/psr.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
xen/arch/x86/psr.c +17 -16
@@ -282,7 +282,7 @@ static enum psr_feat_type psr_type_to_feat_type(enum psr_type type) }/* Implementation of allocation features' functions. */ -static bool cat_check_cbm (const struct feat_node *feat,uint32_t *val) +static bool cf_check cat_check_cbm(const struct feat_node *feat, uint32_t *val) {unsigned int first_bit, zero_bit;unsigned int cbm_len = feat->cat.cbm_len;
@@ -417,8 +417,8 @@ static bool mba_init_feature(const struct cpuid_leaf *regs,return true; } -static bool cat_get_feat_info (const struct feat_node *feat, -uint32_t data[],unsigned int array_len) +static bool cf_check cat_get_feat_info( +const struct feat_node *feat,uint32_t data[],unsigned int array_len) {if ( array_len !=PSR_INFO_ARRAY_SIZE )return false;
@@ -431,8 +431,8 @@ static bool cat_get_feat_info(const struct feat_node *feat, }/* L3 CAT props */ -static void l3_cat_write_msr (unsigned int cos,uint32_t val, -enum psr_type type) +static void cf_check l3_cat_write_msr( +unsigned int cos,uint32_t val,enum psr_type type) {wrmsrl (MSR_IA32_PSR_L3_MASK (cos), val); }
@@ -447,8 +447,8 @@ static const struct feat_props l3_cat_props = { };/* L3 CDP props */ -static bool l3_cdp_get_feat_info (const struct feat_node *feat, -uint32_t data[],uint32_t array_len) +static bool cf_check l3_cdp_get_feat_info( +const struct feat_node *feat,uint32_t data[],uint32_t array_len) {if ( !cat_get_feat_info (feat, data, array_len) )return false;
@@ -458,8 +458,8 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat,return true; } -static void l3_cdp_write_msr (unsigned int cos,uint32_t val, -enum psr_type type) +static void cf_check l3_cdp_write_msr( +unsigned int cos,uint32_t val,enum psr_type type) { wrmsrl(((type == PSR_TYPE_L3_DATA) ? MSR_IA32_PSR_L3_MASK_DATA(cos) :
@@ -478,8 +478,8 @@ static const struct feat_props l3_cdp_props = { };/* L2 CAT props */ -static void l2_cat_write_msr (unsigned int cos,uint32_t val, -enum psr_type type) +static void cf_check l2_cat_write_msr( +unsigned int cos,uint32_t val,enum psr_type type) {wrmsrl (MSR_IA32_PSR_L2_MASK (cos), val); }
@@ -494,8 +494,8 @@ static const struct feat_props l2_cat_props = { };/* MBA props */ -static bool mba_get_feat_info (const struct feat_node *feat, -uint32_t data[],unsigned int array_len) +static bool cf_check mba_get_feat_info( +const struct feat_node *feat,uint32_t data[],unsigned int array_len) {ASSERT (array_len ==PSR_INFO_ARRAY_SIZE );
@@ -508,13 +508,14 @@ static bool mba_get_feat_info(const struct feat_node *feat,return true; } -static void mba_write_msr (unsigned int cos,uint32_t val, -enum psr_type type) +static void cf_check mba_write_msr( +unsigned int cos,uint32_t val,enum psr_type type) {wrmsrl (MSR_IA32_PSR_MBA_MASK (cos), val); } -static bool mba_sanitize_thrtl (const struct feat_node *feat,uint32_t *thrtl) +static bool cf_check mba_sanitize_thrtl( +const struct feat_node *feat,uint32_t *thrtl) {/* * Per SDM (chapter "Memory Bandwidth Allocation Configuration"):
Signature · 1 line
2.11.0
PATCH 50/65 x86/dpci: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 4 ++-- xen/drivers/passthrough/vtd/x86/hvm.c | 4 ++-- xen/drivers/passthrough/x86/hvm.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -2
@@ -513,8 +513,8 @@ void hvm_migrate_pirq(struct hvm_pirq_dpci *pirq_dpci, const struct vcpu *v) } } -static int migrate_pirq (struct domain *d,struct hvm_pirq_dpci *pirq_dpci, -void *arg) +static int cf_check migrate_pirq( +struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) {hvm_migrate_pirq (pirq_dpci, arg);
xen/drivers/passthrough/vtd/x86/hvm.c +2 -2
@@ -21,8 +21,8 @@#include <xen/irq.h> #include <xen/sched.h> -static int _hvm_dpci_isairq_eoi (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) +static int cf_check _hvm_dpci_isairq_eoi( +struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) {struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int isairq = (long )arg;
xen/drivers/passthrough/x86/hvm.c +4 -4
@@ -773,8 +773,8 @@ static void __msi_pirq_eoi(struct hvm_pirq_dpci *pirq_dpci) } } -static int _hvm_dpci_msi_eoi (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) +static int cf_check _hvm_dpci_msi_eoi( +struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) {int vector = (long )arg;
@@ -943,8 +943,8 @@ void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi)spin_unlock (&d->event_lock); } -static int pci_clean_dpci_irq (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) +static int cf_check pci_clean_dpci_irq( +struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) {struct dev_intx_gsi_link *digl, *tmp;
Signature · 1 line
2.11.0
PATCH 51/65 x86/pt: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/emul-i8254.c | 2 +- xen/arch/x86/hvm/hpet.c | 2 +- xen/arch/x86/hvm/rtc.c | 2 +- xen/arch/x86/hvm/vlapic.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/emul-i8254.c +1 -1
@@ -156,7 +156,7 @@ static int pit_get_gate(PITState *pit, int channel)return pit->hw.channels[channel].gate; } -static void pit_time_fired (struct vcpu *v,void *priv) +static void cf_check pit_time_fired(struct vcpu *v, void *priv) {uint64_t *count_load_time = priv;TRACE_0D (TRC_HVM_EMUL_PIT_TIMER_CB );
xen/arch/x86/hvm/hpet.c +1 -1
@@ -219,7 +219,7 @@ static void hpet_stop_timer(HPETState *h, unsigned int tn,hpet_get_comparator (h, tn, guest_time); } -static void hpet_timer_fired (struct vcpu *v,void *data) +static void cf_check hpet_timer_fired(struct vcpu *v, void *data) {unsigned int tn = (unsigned long )data;HPETState *h =vcpu_vhpet (v);
xen/arch/x86/hvm/rtc.c +1 -1
@@ -81,7 +81,7 @@ static void rtc_update_irq(RTCState *s)/* Called by the VPT code after it's injected a PF interrupt for us. * Fix up the register state to reflect what happened. */ -static void rtc_pf_callback (struct vcpu *v,void *opaque) +static void cf_check rtc_pf_callback(struct vcpu *v, void *opaque) {RTCState *s = opaque;
xen/arch/x86/hvm/vlapic.c +2 -2
@@ -691,13 +691,13 @@ int guest_rdmsr_x2apic(const struct vcpu *v, uint32_t msr, uint64_t *val)return X86EMUL_OKAY ; } -static void vlapic_pt_cb (struct vcpu *v,void *data) +static void cf_check vlapic_pt_cb(struct vcpu *v, void *data) {TRACE_0D (TRC_HVM_EMUL_LAPIC_TIMER_CB ); *(s_time_t *)data =hvm_get_guest_time (v); } -static void vlapic_tdt_pt_cb (struct vcpu *v,void *data) +static void cf_check vlapic_tdt_pt_cb(struct vcpu *v, void *data) { *(s_time_t *)data =hvm_get_guest_time (v);vcpu_vlapic (v)->hw.tdt_msr =0 ;
Signature · 1 line
2.11.0
PATCH 52/65 x86/time: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/hpet.c | 8 ++++---- xen/arch/x86/time.c | 33 +++++++++++++++++---------------- xen/include/asm-x86/hpet.h | 4 ++-- 3 files changed, 23 insertions(+), 22 deletions(-)
xen/arch/x86/hpet.c +4 -4
@@ -196,7 +196,7 @@ static void evt_do_broadcast(cpumask_t *mask)cpumask_raise_softirq (mask,TIMER_SOFTIRQ ); } -static void handle_hpet_broadcast (struct hpet_event_channel *ch) +static void cf_check handle_hpet_broadcast(struct hpet_event_channel *ch) {cpumask_t mask;s_time_t now, next_event;
@@ -553,7 +553,7 @@ static void hpet_detach_channel(unsigned int cpu,void (*__read_mostly pv_rtc_handler)(uint8_t index,uint8_t value); -static void handle_rtc_once (uint8_t index,uint8_t value) +static void cf_check handle_rtc_once(uint8_t index, uint8_t value) {if ( index !=RTC_REG_B )return ;
@@ -566,7 +566,7 @@ static void handle_rtc_once(uint8_t index, uint8_t value) } } -void __init hpet_broadcast_init (void ) +void __init cf_check hpet_broadcast_init(void) {u64 hpet_rate =hpet_setup ();u32 hpet_id, cfg;
@@ -637,7 +637,7 @@ void __init hpet_broadcast_init(void) hpet_events->flags =HPET_EVT_LEGACY ; } -void hpet_broadcast_resume (void ) +void cf_check hpet_broadcast_resume(void) {u32 cfg;unsigned int i, n;
xen/arch/x86/time.c +17 -16
@@ -292,7 +292,7 @@ static char *freq_string(u64 freq)* PLATFORM TIMER 1: PROGRAMMABLE INTERVAL TIMER (LEGACY PIT) */ -static u64 read_pit_count (void ) +static u64 cf_check read_pit_count(void) {u16 count16;u32 count32;
@@ -311,7 +311,7 @@ static u64 read_pit_count(void)return count32; } -static s64 __init init_pit (struct platform_timesource *pts) +static s64 __init cf_check init_pit(struct platform_timesource *pts) {u8 portb =inb (0x61 );u64 start, end;
@@ -348,7 +348,7 @@ static s64 __init init_pit(struct platform_timesource *pts)return (end - start) *CALIBRATE_FRAC ; } -static void resume_pit (struct platform_timesource *pts) +static void cf_check resume_pit(struct platform_timesource *pts) {/* Set CTC channel 2 to mode 0 again; initial value does not matter. */ outb (0xb0 ,PIT_MODE );/* binary, mode 0, LSB/MSB, Ch 2 */
@@ -371,12 +371,12 @@ static struct platform_timesource __initdata plt_pit =* PLATFORM TIMER 2: HIGH PRECISION EVENT TIMER (HPET) */ -static u64 read_hpet_count (void ) +static u64 cf_check read_hpet_count(void) {return hpet_read32 (HPET_COUNTER ); } -static int64_t __init init_hpet (struct platform_timesource *pts) +static int64_t __init cf_check init_hpet(struct platform_timesource *pts) {uint64_t hpet_rate, start;uint32_t count, target;
@@ -462,7 +462,7 @@ static int64_t __init init_hpet(struct platform_timesource *pts)return (rdtsc_ordered () - start) *CALIBRATE_FRAC ; } -static void resume_hpet (struct platform_timesource *pts) +static void cf_check resume_hpet(struct platform_timesource *pts) {hpet_resume (NULL ); }
@@ -487,12 +487,12 @@ unsigned int __initdata pmtmr_width;/* ACPI PM timer ticks at 3.579545 MHz. */ #define ACPI_PM_FREQUENCY 3579545 -static u64 read_pmtimer_count (void ) +static u64 cf_check read_pmtimer_count(void) {return inl (pmtmr_ioport); } -static s64 __init init_pmtimer (struct platform_timesource *pts) +static s64 __init cf_check init_pmtimer(struct platform_timesource *pts) {u64 start;u32 count, target, mask;
@@ -557,7 +557,7 @@ static unsigned int __initdata tsc_flags;* Called in verify_tsc_reliability() under reliable TSC conditions * thus reusing all the checks already performed there. */ -static s64 __init init_tsc (struct platform_timesource *pts) +static s64 __init cf_check init_tsc(struct platform_timesource *pts) {u64 ret = pts->frequency;
@@ -579,7 +579,7 @@ static s64 __init init_tsc(struct platform_timesource *pts)return ret; } -static u64 read_tsc (void ) +static u64 cf_check read_tsc(void) {return rdtsc_ordered (); }
@@ -621,7 +621,7 @@ static uint64_t xen_timer_cpu_frequency(void)return freq; } -static int64_t __init init_xen_timer (struct platform_timesource *pts) +static int64_t __init cf_check init_xen_timer(struct platform_timesource *pts) {if ( !xen_guest )return 0 ;
@@ -642,7 +642,7 @@ static always_inline uint64_t read_cycle(const struct vcpu_time_info *info,return info->system_time + offset; } -static uint64_t read_xen_timer (void ) +static uint64_t cf_check read_xen_timer(void) {struct vcpu_time_info *info = &this_cpu (vcpu_info)->time;uint32_t version;
@@ -671,7 +671,7 @@ static uint64_t read_xen_timer(void)return ret; } -static void resume_xen_timer (struct platform_timesource *pts) +static void cf_check resume_xen_timer(struct platform_timesource *pts) {write_atomic (&xen_timer_last,0 ); }
@@ -697,7 +697,8 @@ static struct platform_timesource __initdata plt_xen_timer =static struct ms_hyperv_tsc_page *hyperv_tsc;static struct page_info *hyperv_tsc_page; -static int64_t __init init_hyperv_timer (struct platform_timesource *pts) +static int64_t __init cf_check init_hyperv_timer( +struct platform_timesource *pts) {paddr_t maddr;uint64_t tsc_msr, freq;
@@ -740,7 +741,7 @@ static int64_t __init init_hyperv_timer(struct platform_timesource *pts)return freq; } -static uint64_t read_hyperv_timer (void ) +static uint64_t cf_check read_hyperv_timer(void) {uint64_t scale, ret, tsc;int64_t offset;
@@ -1716,7 +1717,7 @@ time_calibration_rendezvous_tail(const struct calibration_rendezvous *r,* Keep TSCs in sync when they run at the same rate, but may stop in * deep-sleep C states. */ -static void time_calibration_tsc_rendezvous (void *_r) +static void cf_check time_calibration_tsc_rendezvous(void *_r) {int i;struct calibration_rendezvous *r = _r;
xen/include/asm-x86/hpet.h +2 -2
@@ -89,8 +89,8 @@ void hpet_disable_legacy_replacement_mode(void);* Temporarily use an HPET event counter for timer interrupt handling, * rather than using the LAPIC timer. Used for Cx state entry. */ -void hpet_broadcast_init (void ); -void hpet_broadcast_resume (void ); +void cf_check hpet_broadcast_init(void); +void cf_check hpet_broadcast_resume(void); void cf_check hpet_broadcast_enter(void); void cf_check hpet_broadcast_exit(void);int hpet_broadcast_is_available (void );
Signature · 1 line
2.11.0
PATCH 53/65 x86/misc: Annotate fnptr targets
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/extable.c | 4 ++-- xen/common/efi/boot.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/extable.c +2 -2
@@ -23,7 +23,7 @@ static inline unsigned long ex_cont(const struct exception_table_entry *x)return EX_FIELD (x, cont); } -static int init_or_livepatch cmp_ex(const void *a, const void *b) +static int init_or_livepatch cf_check cmp_ex(const void *a, const void *b) {const struct exception_table_entry *l = a, *r = b;unsigned long lip =ex_addr (l);
@@ -37,7 +37,7 @@ static int init_or_livepatch cmp_ex(const void *a, const void *b)return 0 ; } -static void init_or_livepatch swap_ex(void *a, void *b, size_t size) +static void init_or_livepatch cf_check swap_ex(void *a, void *b, size_t size) {struct exception_table_entry *l = a, *r = b, tmp;long delta = b - a;
xen/common/efi/boot.c +2 -2
@@ -1504,7 +1504,7 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end,unmap_domain_page (l3dst); } -static bool __init ram_range_valid (unsigned long smfn,unsigned long emfn) +static bool __init cf_check ram_range_valid(unsigned long smfn, unsigned long emfn) {unsigned long sz =pfn_to_pdx (emfn -1 ) /PDX_GROUP_COUNT +1 ;
@@ -1513,7 +1513,7 @@ static bool __init ram_range_valid(unsigned long smfn, unsigned long emfn) pfn_to_pdx(smfn) / PDX_GROUP_COUNT) < sz; } -static bool __init rt_range_valid (unsigned long smfn,unsigned long emfn) +static bool __init cf_check rt_range_valid(unsigned long smfn, unsigned long emfn) {return true; }
Signature · 1 line
2.11.0
PATCH 54/65 x86/stack: Annotate fnptr targets
In reply to Andrew CooperThe function typecheck in switch_stack_and_jump() is incompatible with control flow typechecking. It's ok for reset_stack_and_jump_ind(), but for reset_stack_and_jump(), it would force us to ENDBR64 the targets which are branched to directly.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
Honestly, the control flow typechecking is distinctly sub-par, but it's too late to do anything now.
--- xen/arch/x86/domain.c | 6 +++--- xen/arch/x86/hvm/svm/svm.c | 6 +++--- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 8 ++++---- xen/arch/x86/pv/domain.c | 2 +- xen/arch/x86/x86_64/entry.S | 1 + xen/include/asm-x86/current.h | 2 +- xen/include/asm-x86/hvm/vmx/vmx.h | 2 +- xen/include/asm-x86/pv/domain.h | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-)
xen/arch/x86/domain.c +3 -3
@@ -132,7 +132,7 @@ void play_dead(void)dead_idle (); } -static void noreturnidle_loop (void ) +static void noreturn cf_check idle_loop(void) {unsigned int cpu =smp_processor_id ();/*
@@ -1790,7 +1790,7 @@ static void save_segments(struct vcpu *v) } } -void paravirt_ctxt_switch_from (struct vcpu *v) +void cf_check paravirt_ctxt_switch_from(struct vcpu *v) {save_segments (v);
@@ -1804,7 +1804,7 @@ void paravirt_ctxt_switch_from(struct vcpu *v)write_debugreg (7 ,0 ); } -void paravirt_ctxt_switch_to (struct vcpu *v) +void cf_check paravirt_ctxt_switch_to(struct vcpu *v) {root_pgentry_t *root_pgt =this_cpu (root_pgt);
xen/arch/x86/hvm/svm/svm.c +3 -3
@@ -940,7 +940,7 @@ static inline void svm_tsc_ratio_load(struct vcpu *v)wrmsrl (MSR_AMD64_TSC_RATIO ,hvm_tsc_scaling_ratio (v->domain)); } -static void svm_ctxt_switch_from (struct vcpu *v) +static void cf_check svm_ctxt_switch_from(struct vcpu *v) {int cpu =smp_processor_id ();
@@ -965,7 +965,7 @@ static void svm_ctxt_switch_from(struct vcpu *v)enable_each_ist (idt_tables[cpu]); } -static void svm_ctxt_switch_to (struct vcpu *v) +static void cf_check svm_ctxt_switch_to(struct vcpu *v) {struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;int cpu =smp_processor_id ();
@@ -992,7 +992,7 @@ static void svm_ctxt_switch_to(struct vcpu *v)wrmsr_tsc_aux (v->arch.msrs->tsc_aux); } -static void noreturnsvm_do_resume (void ) +static void noreturn cf_check svm_do_resume(void) {struct vcpu *v = current;struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
xen/arch/x86/hvm/vmx/vmcs.c +1 -1
@@ -1865,7 +1865,7 @@ void vmx_vmentry_failure(void)void noreturnvmx_asm_do_vmentry (void ); -void vmx_do_resume (void ) +void cf_check vmx_do_resume(void) {struct vcpu *v = current;bool_t debug_state;
xen/arch/x86/hvm/vmx/vmx.c +4 -4
@@ -63,8 +63,8 @@static bool_t __initdata opt_force_ept;boolean_param ("force-ept" , opt_force_ept); -static void vmx_ctxt_switch_from (struct vcpu *v); -static void vmx_ctxt_switch_to (struct vcpu *v); +static void cf_check vmx_ctxt_switch_from(struct vcpu *v); +static void cf_check vmx_ctxt_switch_to(struct vcpu *v);static int alloc_vlapic_mapping (void );static void vmx_install_vlapic_mapping (struct vcpu *v);
@@ -885,7 +885,7 @@ static void cf_check vmx_fpu_leave(struct vcpu *v) } } -static void vmx_ctxt_switch_from (struct vcpu *v) +static void cf_check vmx_ctxt_switch_from(struct vcpu *v) {/* * Return early if trying to do a context switch without VMX enabled,
@@ -917,7 +917,7 @@ static void vmx_ctxt_switch_from(struct vcpu *v)vmx_pi_switch_from (v); } -static void vmx_ctxt_switch_to (struct vcpu *v) +static void cf_check vmx_ctxt_switch_to(struct vcpu *v) {vmx_restore_guest_msrs (v);vmx_restore_dr (v);
xen/arch/x86/pv/domain.c +1 -1
@@ -351,7 +351,7 @@ void pv_domain_destroy(struct domain *d)FREE_XENHEAP_PAGE (d->arch.pv.gdt_ldt_l1tab); } -void noreturncontinue_pv_domain (void ); +void noreturn cf_check continue_pv_domain(void);int pv_domain_initialise (struct domain *d) {
xen/arch/x86/x86_64/entry.S +1 -0
@@ -625,6 +625,7 @@ ENTRY(dom_crash_sync_extable) /* No special register assumptions. */ #ifdef CONFIG_PV ENTRY(continue_pv_domain) + ENDBR64 call check_wakeup_from_wait ret_from_intr: GET_CURRENT(bx)
xen/include/asm-x86/current.h +1 -1
@@ -173,7 +173,6 @@ unsigned long get_stack_dump_bottom (unsigned long sp);#define switch_stack_and_jump (fn, instr, constr) \ ({ \ unsigned int tmp; \ - (void)((fn) == (void (*)(void))NULL); \ BUILD_BUG_ON(!ssaj_has_attr_noreturn(fn)); \ __asm__ __volatile__ ( \ SHADOW_STACK_WORK \
@@ -198,6 +197,7 @@ unsigned long get_stack_dump_bottom (unsigned long sp);/* The constraint may only specify non-call-clobbered registers. */ #define reset_stack_and_jump_ind (fn) \ + (void)((fn) == (void (*)(void))NULL); \ switch_stack_and_jump(fn, "INDIRECT_JMP %", "b")/*
xen/include/asm-x86/hvm/vmx/vmx.h +1 -1
@@ -93,7 +93,7 @@ typedef enum {void vmx_asm_vmexit_handler (struct cpu_user_regs );void vmx_intr_assist (void ); -void noreturnvmx_do_resume (void ); +void noreturn cf_check vmx_do_resume(void);void vmx_vlapic_msr_changed (struct vcpu *v);struct hvm_emulate_ctxt ;void vmx_realmode_emulate_one (struct hvm_emulate_ctxt *hvmemul_ctxt);
xen/include/asm-x86/pv/domain.h +2 -2
@@ -104,8 +104,8 @@ static inline unsigned long pv_make_cr4(const struct vcpu *v) { return ~0ul; }#endif /* CONFIG_PV */ -void paravirt_ctxt_switch_from (struct vcpu *v); -void paravirt_ctxt_switch_to (struct vcpu *v); +void cf_check paravirt_ctxt_switch_from(struct vcpu *v); +void cf_check paravirt_ctxt_switch_to(struct vcpu *v);#endif /* __X86_PV_DOMAIN_H__ */
Signature · 1 line
2.11.0
Re: [PATCH 54/65] x86/stack: Annotate fnptr targets
Quoted 11 lines · Andrew Cooper
xen/include/asm-x86/current.h +0
-1@@ -173,7 +173,6 @@ unsigned long get_stack_dump_bottom (unsigned long sp);#define switch_stack_and_jump (fn, instr, constr) \ ({ \ unsigned int tmp; \ - (void)((fn) == (void (*)(void))NULL); \ BUILD_BUG_ON(!ssaj_has_attr_noreturn(fn)); \ __asm__ __volatile__ ( \ SHADOW_STACK_WORK \
xen/include/asm-x86/current.h unsigned long get_stack_dump_bottom (unsigned long sp); · line 202
Quoted 6 lines
xen/include/asm-x86/current.h +1
-0@@ -198,6 +197,7 @@ unsigned long get_stack_dump_bottom (unsigned long sp);/* The constraint may only specify non-call-clobbered registers. */ #define reset_stack_and_jump_ind (fn) \ + (void)((fn) == (void (*)(void))NULL); \ switch_stack_and_jump(fn, "INDIRECT_JMP %", "b")
While the risk of use in a context really requiring it is low, I still think we'd be better off wrapping the whole thing in ({ }) then.
Jan
PATCH 55/65 x86/bugframe: Annotate fnptr targets
In reply to Andrew Cooperrun_in_exception_handler() managed to escape typechecking, as the compiler can't see where function pointer gets called. After adding some ad-hoc typechecking, it turns out that dump_execution_state() alone differs in const-ness from the other users of run_in_exception_handler().
Introduce a new show_execution_state_nonconst() to make the typechecking happy.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/traps.c | 5 +++++ xen/common/keyhandler.c | 4 ++-- xen/drivers/char/ehci-dbgp.c | 2 +- xen/drivers/char/ns16550.c | 2 +- xen/include/asm-x86/bug.h | 10 +++++++++- xen/include/asm-x86/processor.h | 4 +++- xen/include/xen/lib.h | 2 +- 7 files changed, 22 insertions(+), 7 deletions(-)
xen/arch/x86/traps.c +5 -0
@@ -670,6 +670,11 @@ void show_execution_state(const struct cpu_user_regs *regs)console_unlock_recursive_irqrestore (flags); } +void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs) +{ +show_execution_state (regs); +} +void vcpu_show_execution_state (struct vcpu *v) {unsigned long flags =0 ;
xen/common/keyhandler.c +2 -2
@@ -138,7 +138,7 @@ static void cf_check show_handlers(unsigned char key)static cpumask_t dump_execstate_mask; -void dump_execstate (struct cpu_user_regs *regs) +void cf_check dump_execstate(struct cpu_user_regs *regs) {unsigned int cpu =smp_processor_id ();
@@ -490,7 +490,7 @@ static void cf_check run_all_keyhandlers(tasklet_schedule (&run_all_keyhandlers_tasklet); } -static void do_debugger_trap_fatal (struct cpu_user_regs *regs) +static void cf_check do_debugger_trap_fatal(struct cpu_user_regs *regs) { (void )debugger_trap_fatal (0xf001 , regs);
xen/drivers/char/ehci-dbgp.c +1 -1
@@ -1247,7 +1247,7 @@ static int cf_check ehci_dbgp_getc(struct serial_port *port, char *pc)/* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */ static struct serial_port *poll_port; -static void _ehci_dbgp_poll (struct cpu_user_regs *regs) +static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs) {struct serial_port *port = poll_port;struct ehci_dbgp *dbgp = port->uart;
xen/drivers/char/ns16550.c +1 -1
@@ -206,7 +206,7 @@ static void cf_check ns16550_interrupt(/* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */ static DEFINE_PER_CPU(struct serial_port *, poll_port); -static void __ns16550_poll (struct cpu_user_regs *regs) +static void cf_check __ns16550_poll(struct cpu_user_regs *regs) {struct serial_port *port =this_cpu (poll_port);struct ns16550 *uart = port->uart;
xen/include/asm-x86/bug.h +9 -1
@@ -65,7 +65,15 @@ struct bug_frame {unreachable (); \ }while (0 ) -#define run_in_exception_handler (fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL) +/* +* TODO: untangle header dependences, break BUILD_BUG_ON() out of xen/lib.h, +* and use a real static inline here to get proper type checking of fn(). + */ +#define run_in_exception_handler (fn) \ + do { \ + (void)((fn) == (void (*)(struct cpu_user_regs *))NULL); \ + BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL); \ + } while ( 0 )#define assert_failed (msg) do { \ BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \
xen/include/asm-x86/processor.h +3 -1
@@ -497,7 +497,9 @@ 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 (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 cf_check show_execution_state_nonconst(struct cpu_user_regs *regs); +#define dump_execution_state () \ + run_in_exception_handler(show_execution_state_nonconst)void show_page_walk (unsigned long addr);void noreturnfatal_trap (const struct cpu_user_regs *regs,bool_t show_remote);
xen/include/xen/lib.h +1 -1
@@ -199,7 +199,7 @@ extern char *print_tainted(char *str);extern void add_taint (unsigned int taint);struct cpu_user_regs ; -void dump_execstate (struct cpu_user_regs *); +void cf_check dump_execstate(struct cpu_user_regs *);void init_constructors (void );
Signature · 1 line
2.11.0
PATCH 56/65 x86: Use control flow typechecking where possible
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
RFC. This is still an experimental compiler extention
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102953
However, it is also the entire basis of being able to sanely use -mmanual-endbr in the first place, so is very important.
--- xen/arch/x86/arch.mk | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/arch.mk +1 -0
@@ -48,6 +48,7 @@ CFLAGS-$(CONFIG_INDIRECT_THUNK) += -fno-jump-tables ifdef CONFIG_HAS_CC_CET_IBT CFLAGS += -fcf-protection=branch -mmanual-endbr +$(call cc-option-add,CFLAGS,CC,-fcf-check-attribute=no) else $(call cc-option-add,CFLAGS,CC,-fcf-protection=none) endif
Signature · 1 line
2.11.0
PATCH 57/65 x86/setup: Read CR4 earlier in __start_xen()
In reply to Andrew CooperThis is necessary for read_cr4() to function correctly. Move the EFER caching at the same time.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/setup.c +3 -3
@@ -872,6 +872,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)/* Full exception support from here on in. */ +rdmsrl (MSR_EFER ,this_cpu (efer)); + asmvolatile ("mov %%cr4,%0" :"=r" (get_cpu_info ()->cr4) ); +/* Enable NMIs. Our loader (e.g. Tboot) may have left them disabled. */ enable_nmis ();
@@ -918,9 +921,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)parse_video_info (); -rdmsrl (MSR_EFER ,this_cpu (efer)); - asmvolatile ("mov %%cr4,%0" :"=r" (get_cpu_info ()->cr4) ); -/* We initialise the serial devices very early so we can get debugging. */ ns16550.io_base =0x3f8 ; ns16550.irq =4 ;
Signature · 1 line
2.11.0
Re: [PATCH 57/65] x86/setup: Read CR4 earlier in __start_xen()
Quoted 4 lines · Andrew Cooper
This is necessary for
read_cr4()to function correctly. Move the EFER caching at the same time.Signed-off-by Andrew Cooper <[email protected]>
PATCH 58/65 x86/alternatives: Clear CR4.CET when clearing CR0.WP
In reply to Andrew CooperThis allows us to have CET active much earlier in boot.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
Still TODO: Implement alternatives in a way which doesn't depend on clearing CR0.WP
--- xen/arch/x86/alternative.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
xen/arch/x86/alternative.c +8 -1
@@ -333,9 +333,13 @@ static int __init cf_check nmi_apply_alternatives(*/ if ( !(alt_done & alt_todo) ) { -unsigned long cr0; +unsigned long cr0, cr4; cr0 =read_cr0 (); + cr4 =read_cr4 (); + +if ( cr4 &X86_CR4_CET ) +write_cr4 (cr4 & ~X86_CR4_CET );/* Disable WP to allow patching read-only pages. */ write_cr0 (cr0 & ~X86_CR0_WP );
@@ -345,6 +349,9 @@ static int __init cf_check nmi_apply_alternatives(write_cr0 (cr0); +if ( cr4 &X86_CR4_CET ) +write_cr4 (cr4); + alt_done |= alt_todo; }
Signature · 1 line
2.11.0
Re: [PATCH 58/65] x86/alternatives: Clear CR4.CET when clearing CR0.WP
Quoted 3 lines · Andrew Cooper
This allows us to have CET active much earlier in boot.
Signed-off-by Andrew Cooper <[email protected]>
PATCH 59/65 x86/traps: Rework write_stub_trampoline() to not hardcode the jmp
In reply to Andrew CooperFor CET-IBT, we will need to optionally insert an endbr64 instruction at the start of the stub. Don't hardcode the jmp displacement assuming that it starts at byte 24 of the stub.
Also add extra comments describing what is going on. The mix of %rax and %rsp is far from trivial to follow.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/x86_64/traps.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
xen/arch/x86/x86_64/traps.c +22 -14
@@ -293,30 +293,38 @@ static unsigned int write_stub_trampoline( unsigned char *stub, unsigned long stub_va, unsigned long stack_bottom, unsigned long target_va) { + unsigned char *p = stub; + +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ - stub[0 ] =0x48 ; - stub[1 ] =0xa3 ; - *(uint64_t *)&stub[2 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xa3 ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp in %rax */ /* movq %rsp, %rax */ - stub[10 ] =0x48 ; - stub[11 ] =0x89 ; - stub[12 ] =0xe0 ; + *p++ =0x48 ; + *p++ =0x89 ; + *p++ =0xe0 ; +/* Switch to Xen stack */ /* movabsq $stack_bottom - 8, %rsp */ - stub[13 ] =0x48 ; - stub[14 ] =0xbc ; - *(uint64_t *)&stub[15 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xbc ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp into %rsp slot */ /* pushq %rax */ - stub[23 ] =0x50 ; + *p++ =0x50 ;/* jmp target_va */ - stub[24 ] =0xe9 ; - *(int32_t *)&stub[25 ] = target_va - (stub_va +29 ); + *p++ =0xe9 ; + *(int32_t *)p = target_va - (stub_va + (p - stub) +4 ); + p +=4 ; -/* Round up to a multiple of 16 bytes. */ -return 32 ; +return p - stub; } DEFINE_PER_CPU(struct stubs, stubs);
Signature · 1 line
2.11.0
Re: [PATCH 59/65] x86/traps: Rework write_stub_trampoline() to not hardcode the jmp
Quoted 61 lines · Andrew Cooper
For CET-IBT, we will need to optionally insert an endbr64 instruction at the start of the stub. Don't hardcode the jmp displacement assuming that it starts at byte 24 of the stub.
Also add extra comments describing what is going on. The mix of %rax and %rsp is far from trivial to follow.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>--- xen/arch/x86/x86_64/traps.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)xen/arch/x86/x86_64/traps.c +18
-10@@ -293,30 +293,38 @@ static unsigned int write_stub_trampoline( unsigned char *stub, unsigned long stub_va, unsigned long stack_bottom, unsigned long target_va) { + unsigned char *p = stub; + +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ - stub[0 ] =0x48 ; - stub[1 ] =0xa3 ; - *(uint64_t *)&stub[2 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xa3 ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp in %rax */ /* movq %rsp, %rax */ - stub[10 ] =0x48 ; - stub[11 ] =0x89 ; - stub[12 ] =0xe0 ; + *p++ =0x48 ; + *p++ =0x89 ; + *p++ =0xe0 ; +/* Switch to Xen stack */ /* movabsq $stack_bottom - 8, %rsp */ - stub[13 ] =0x48 ; - stub[14 ] =0xbc ; - *(uint64_t *)&stub[15 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xbc ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp into %rsp slot */ /* pushq %rax */ - stub[23 ] =0x50 ; + *p++ =0x50 ;/* jmp target_va */
xen/arch/x86/x86_64/traps.c static unsigned int write_stub_trampoline( · line 328
Quoted 10 lines
xen/arch/x86/x86_64/traps.c +4
-4- stub[24 ] =0xe9 ; - *(int32_t *)&stub[25 ] = target_va - (stub_va +29 ); + *p++ =0xe9 ; + *(int32_t *)p = target_va - (stub_va + (p - stub) +4 ); + p +=4 ; -/* Round up to a multiple of 16 bytes. */ -return 32 ; +return p - stub; }
I'm concerned of you silently discarding the aligning to 16 bytes here. Imo this really needs justifying, or perhaps even delaying until a later change. I'd like to point out though that we may not have a space issue here at all, as I think we can replace one of the MOVABSQ (using absolute numbers to hopefully make this easier to follow):
movabsq %rax, stack_bottom - 8
movq %rsp, %rax
movq -18(%rip), %rsp
pushq %rax
jmp target_va
This totals to 26 bytes, leaving enough room for ENDBR64 without crossing the 32-byte boundary. But I fear you may eat me for using insn bytes as data ...
Jan
Re: [PATCH 59/65] x86/traps: Rework write_stub_trampoline() to not hardcode the jmp
Quoted 68 lines · Jan Beulich
Quoted 67 lines · Andrew Cooper
For CET-IBT, we will need to optionally insert an endbr64 instruction at the start of the stub. Don't hardcode the jmp displacement assuming that it starts at byte 24 of the stub.
Also add extra comments describing what is going on. The mix of %rax and %rsp is far from trivial to follow.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>--- xen/arch/x86/x86_64/traps.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)xen/arch/x86/x86_64/traps.c +21
-12@@ -293,30 +293,38 @@ static unsigned int write_stub_trampoline( unsigned char *stub, unsigned long stub_va, unsigned long stack_bottom, unsigned long target_va) { + unsigned char *p = stub; + +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ - stub[0 ] =0x48 ; - stub[1 ] =0xa3 ; - *(uint64_t *)&stub[2 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xa3 ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp in %rax */ /* movq %rsp, %rax */ - stub[10 ] =0x48 ; - stub[11 ] =0x89 ; - stub[12 ] =0xe0 ; + *p++ =0x48 ; + *p++ =0x89 ; + *p++ =0xe0 ; +/* Switch to Xen stack */ /* movabsq $stack_bottom - 8, %rsp */ - stub[13 ] =0x48 ; - stub[14 ] =0xbc ; - *(uint64_t *)&stub[15 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xbc ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp into %rsp slot */ /* pushq %rax */ - stub[23 ] =0x50 ; + *p++ =0x50 ;/* jmp target_va */ - stub[24 ] =0xe9 ; - *(int32_t *)&stub[25 ] = target_va - (stub_va +29 ); + *p++ =0xe9 ; + *(int32_t *)p = target_va - (stub_va + (p - stub) +4 ); + p +=4 ;
Quoted 7 lines
xen/arch/x86/x86_64/traps.c static unsigned int write_stub_trampoline( · line 328
Quoted 4 lines
xen/arch/x86/x86_64/traps.c +1
-2-/* Round up to a multiple of 16 bytes. */ -return 32 ; +return p - stub; }I'm concerned of you silently discarding the aligning to 16 bytes here. Imo this really needs justifying, or perhaps even delaying until a later change.
Oh. That was an oversight, and I'm honestly a little impressed that the result worked fine.
return ROUNDUP(p - stub, 16);
ought to do?
Quoted 10 lines
I'd like to point out though that we may not have a space
issue here at all, as I think we can replace one of the MOVABSQ (using absolute numbers to hopefully make this easier to follow):movabsq %rax,
stack_bottom- 8
movq %rsp, %rax
movq -18(%rip), %rsp
pushq %rax
jmptarget_va
Quoted 3 lines
This totals to 26 bytes, leaving enough room for ENDBR64 without crossing the 32-byte boundary. But I fear you may eat me for using insn bytes as data ...
Well that's entertaining, and really quite a shame that RIP-relative addresses only work with 32bit displacements.
While it is shorter, it's only 3 bytes shorter, and the stack layout is custom anyway so it really doesn't matter if the push lives here or not.
Furthermore (and probably scraping the excuses barrel here), it forces a data side TLB and cacheline fill where we didn't have one previously. Modern CPUs ought to be fine here, but older ones (that don't have a shared L2TLB) are liable to stall.
Perhaps lets leave this as an emergency option, if we need to find more space again in the future?
~Andrew
Jan Beulich
Reviewed-byRe: [PATCH 59/65] x86/traps: Rework write_stub_trampoline() to not hardcode the jmp
Quoted 77 lines · Andrew Cooper
Quoted 68 lines · Jan Beulich
Quoted 67 lines · Andrew Cooper
For CET-IBT, we will need to optionally insert an endbr64 instruction at the start of the stub. Don't hardcode the jmp displacement assuming that it starts at byte 24 of the stub.
Also add extra comments describing what is going on. The mix of %rax and %rsp is far from trivial to follow.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>--- xen/arch/x86/x86_64/traps.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)xen/arch/x86/x86_64/traps.c +21
-12@@ -293,30 +293,38 @@ static unsigned int write_stub_trampoline( unsigned char *stub, unsigned long stub_va, unsigned long stack_bottom, unsigned long target_va) { + unsigned char *p = stub; + +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ - stub[0 ] =0x48 ; - stub[1 ] =0xa3 ; - *(uint64_t *)&stub[2 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xa3 ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp in %rax */ /* movq %rsp, %rax */ - stub[10 ] =0x48 ; - stub[11 ] =0x89 ; - stub[12 ] =0xe0 ; + *p++ =0x48 ; + *p++ =0x89 ; + *p++ =0xe0 ; +/* Switch to Xen stack */ /* movabsq $stack_bottom - 8, %rsp */ - stub[13 ] =0x48 ; - stub[14 ] =0xbc ; - *(uint64_t *)&stub[15 ] = stack_bottom -8 ; + *p++ =0x48 ; + *p++ =0xbc ; + *(uint64_t *)p = stack_bottom -8 ; + p +=8 ; +/* Store guest %rsp into %rsp slot */ /* pushq %rax */ - stub[23 ] =0x50 ; + *p++ =0x50 ;/* jmp target_va */ - stub[24 ] =0xe9 ; - *(int32_t *)&stub[25 ] = target_va - (stub_va +29 ); + *p++ =0xe9 ; + *(int32_t *)p = target_va - (stub_va + (p - stub) +4 ); + p +=4 ;Quoted 7 lines
xen/arch/x86/x86_64/traps.c static unsigned int write_stub_trampoline( · line 328
Quoted 4 lines
xen/arch/x86/x86_64/traps.c +1
-2-/* Round up to a multiple of 16 bytes. */ -return 32 ; +return p - stub; }I'm concerned of you silently discarding the aligning to 16 bytes here. Imo this really needs justifying, or perhaps even delaying until a later change.
Quoted 6 lines
Oh. That was an oversight, and I'm honestly a little impressed that the result worked fine.
return
ROUNDUP(p - stub, 16);ought to do?
Yes, sure. Then
Quoted 17 lines
Quoted 10 lines
I'd like to point out though that we may not have a space
issue here at all, as I think we can replace one of the MOVABSQ (using absolute numbers to hopefully make this easier to follow):movabsq %rax,
stack_bottom- 8
movq %rsp, %rax
movq -18(%rip), %rsp
pushq %rax
jmptarget_vaQuoted 3 lines
This totals to 26 bytes, leaving enough room for ENDBR64 without crossing the 32-byte boundary. But I fear you may eat me for using insn bytes as data ...
Well that's entertaining, and really quite a shame that RIP-relative addresses only work with 32bit displacements.
Quoted 7 lines
While it is shorter, it's only 3 bytes shorter, and the stack layout is custom anyway so it really doesn't matter if the push lives here or not.
Furthermore (and probably scraping the excuses barrel here), it forces a data side TLB and cacheline fill where we didn't have one previously. Modern CPUs ought to be fine here, but older ones (that don't have a shared L2TLB) are liable to stall.
Well, that was why I though you might eat me for the suggestion.
Quoted 2 lines
Perhaps lets leave this as an emergency option, if we need to find more space again in the future?
Yeah - as said elsewhere, due to the v1.1-s I did look at patches in the wrong order, and hence wasn't aware yet that you have found a different way to squeeze in the ENDBR.
Jan
PATCH 60/65 x86/emul: Update emulation stubs to be CET-IBT compatible
In reply to Andrew CooperAll indirect branches need to land on an endbr64 instruction.
For stub_selftests(), use endbr64 unconditionally for simplicity. For ioport and instruction emulation, add endbr64 conditionally.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/extable.c | 14 +++++++++----- xen/arch/x86/pv/emul-priv-op.c | 5 +++++ xen/arch/x86/x86_emulate.c | 12 ++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-)
xen/arch/x86/extable.c +9 -5
@@ -129,19 +129,23 @@ search_exception_table(const struct cpu_user_regs *regs) static int __init cf_check stub_selftest(void) {static const struct { -uint8_t opc[4 ]; +uint8_t opc[8 ];uint64_t rax;union stub_exception_token res; } tests[]__initconst = { - { .opc = {0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ .res.fields.trapnr = TRAP_invalid_op }, - { .opc = {0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ .rax =0x0123456789abcdef , .res.fields.trapnr = TRAP_gp_fault }, - { .opc = {0x02 ,0x04 ,0x04 ,0xc3 },/* add (%rsp,%rax),%al */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x02 ,0x04 ,0x04 ,0xc3 },/* add (%rsp,%rax),%al */ .rax =0xfedcba9876543210 , .res.fields.trapnr = TRAP_stack_error }, - { .opc = {0xcc ,0xc3 ,0xc3 ,0xc3 },/* int3 */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0xcc ,0xc3 ,0xc3 ,0xc3 },/* int3 */ .res.fields.trapnr = TRAP_int3 }, };unsigned long addr =this_cpu (stubs.addr) +STUB_BUF_SIZE /2 ;
xen/arch/x86/pv/emul-priv-op.c +5 -0
@@ -68,6 +68,9 @@ static io_emul_stub_t *io_emul_stub_setup(struct priv_op_ctxt *ctxt, u8 opcode,* helpers (non-standard ABI), and one of several possible stubs * performing the real I/O. */ +static const char endbr64[] = { +0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ + };static const char prologue[] = {0x53 ,/* push %rbx */ 0x55 ,/* push %rbp */
@@ -111,6 +114,8 @@ static io_emul_stub_t *io_emul_stub_setup(struct priv_op_ctxt *ctxt, u8 opcode, p = ctxt->io_emul_stub; +if ( cpu_has_xen_ibt ) +APPEND_BUFF (endbr64);APPEND_BUFF (prologue);APPEND_CALL (load_guest_gprs);
xen/arch/x86/x86_emulate.c +10 -2
@@ -29,11 +29,19 @@ cpu_has_amd_erratum(¤t_cpu_data, AMD_ERRATUM_##nr)#define get_stub (stb) ({ \ + void *ptr; \ BUILD_BUG_ON(STUB_BUF_SIZE / 2 < MAX_INST_LEN + 1); \ ASSERT(!(stb).ptr); \ (stb).addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2; \ - memset(((stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn)))) + \ - ((stb).addr & ~PAGE_MASK), 0xcc, STUB_BUF_SIZE / 2); \ + (stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn))) + \ + ((stb).addr & ~PAGE_MASK); \ + ptr = memset((stb).ptr, 0xcc, STUB_BUF_SIZE / 2); \ + if ( cpu_has_xen_ibt ) \ + { \ + memcpy(ptr, "\xf3\x0f\x1e\xfa", 4);/* endbr64 */ \ + ptr +=4 ; \ + } \ + ptr; \ })#define put_stub (stb) ({ \ if ( (stb).ptr ) \
Signature · 1 line
2.11.0
PATCH 60/65 x86/emul: Update emulation stubs to be CET-IBT compatible
In reply to Andrew CooperAll indirect branches need to land on an endbr64 instruction.
For stub_selftests(), use endbr64 unconditionally for simplicity. For ioport and instruction emulation, add endbr64 conditionally.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
v2:
* Update to use endbr helpers
--- xen/arch/x86/extable.c | 14 +++++++++----- xen/arch/x86/pv/emul-priv-op.c | 7 +++++++ xen/arch/x86/x86_emulate.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-)
xen/arch/x86/extable.c +9 -5
@@ -129,19 +129,23 @@ search_exception_table(const struct cpu_user_regs *regs) static int __init cf_check stub_selftest(void) {static const struct { -uint8_t opc[4 ]; +uint8_t opc[8 ];uint64_t rax;union stub_exception_token res; } tests[]__initconst = { - { .opc = {0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ .res.fields.trapnr = TRAP_invalid_op }, - { .opc = {0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ .rax =0x0123456789abcdef , .res.fields.trapnr = TRAP_gp_fault }, - { .opc = {0x02 ,0x04 ,0x04 ,0xc3 },/* add (%rsp,%rax),%al */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x02 ,0x04 ,0x04 ,0xc3 },/* add (%rsp,%rax),%al */ .rax =0xfedcba9876543210 , .res.fields.trapnr = TRAP_stack_error }, - { .opc = {0xcc ,0xc3 ,0xc3 ,0xc3 },/* int3 */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0xcc ,0xc3 ,0xc3 ,0xc3 },/* int3 */ .res.fields.trapnr = TRAP_int3 }, };unsigned long addr =this_cpu (stubs.addr) +STUB_BUF_SIZE /2 ;
xen/arch/x86/pv/emul-priv-op.c +7 -0
@@ -26,6 +26,7 @@#include <asm/amd.h> #include <asm/debugreg.h> +#include <asm/endbr.h> #include <asm/hpet.h> #include <asm/hypercall.h> #include <asm/mc146818rtc.h>
@@ -111,6 +112,12 @@ static io_emul_stub_t *io_emul_stub_setup(struct priv_op_ctxt *ctxt, u8 opcode, p = ctxt->io_emul_stub; +if ( cpu_has_xen_ibt ) + { +place_endbr64 (p); + p +=4 ; + } +APPEND_BUFF (prologue);APPEND_CALL (load_guest_gprs);
xen/arch/x86/x86_emulate.c +11 -2
@@ -17,6 +17,7 @@#include <asm/xstate.h> #include <asm/amd.h> /* cpu_has_amd_erratum() */ #include <asm/debugreg.h> +#include <asm/endbr.h> /* Avoid namespace pollution. */ #undef cmpxchg
@@ -29,11 +30,19 @@ cpu_has_amd_erratum(¤t_cpu_data, AMD_ERRATUM_##nr)#define get_stub (stb) ({ \ + void *ptr; \ BUILD_BUG_ON(STUB_BUF_SIZE / 2 < MAX_INST_LEN + 1); \ ASSERT(!(stb).ptr); \ (stb).addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2; \ - memset(((stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn)))) + \ - ((stb).addr & ~PAGE_MASK), 0xcc, STUB_BUF_SIZE / 2); \ + (stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn))) + \ + ((stb).addr & ~PAGE_MASK); \ + ptr = memset((stb).ptr, 0xcc, STUB_BUF_SIZE / 2); \ + if ( cpu_has_xen_ibt ) \ + { \ + place_endbr64(ptr); \ + ptr += 4; \ + } \ + ptr; \ })#define put_stub (stb) ({ \ if ( (stb).ptr ) \
Signature · 1 line
2.11.0
Re: [PATCH v1.1 60/65] x86/emul: Update emulation stubs to be CET-IBT compatible
Quoted 20 lines · Andrew Cooper
xen/arch/x86/extable.c +5
-3@@ -129,19 +129,23 @@ search_exception_table(const struct cpu_user_regs *regs) static int __init cf_check stub_selftest(void) {static const struct { -uint8_t opc[4 ]; +uint8_t opc[8 ];uint64_t rax;union stub_exception_token res; } tests[]__initconst = { - { .opc = {0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x0f ,0xb9 ,0xc3 ,0xc3 },/* ud1 */ .res.fields.trapnr = TRAP_invalid_op }, - { .opc = {0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ + { .opc = {0xf3 ,0x0f ,0x1e ,0xfa ,/* endbr64 */ +0x90 ,0x02 ,0x00 ,0xc3 },/* nop; add (%rax),%al */ .rax =0x0123456789abcdef , .res.fields.trapnr = TRAP_gp_fault },
xen/arch/x86/extable.c search_exception_table(const struct cpu_user_regs *regs) · line 150
Quoted 10 lines
xen/arch/x86/extable.c +4
-2- { .opc = { 0x02, 0x04, 0x04, 0xc3 }, /* add (%rsp,%rax),%al */ + { .opc = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ + 0x02, 0x04, 0x04, 0xc3 }, /* add (%rsp,%rax),%al */ .rax = 0xfedcba9876543210, .res.fields.trapnr = TRAP_stack_error }, - { .opc = { 0xcc, 0xc3, 0xc3, 0xc3 }, /* int3 */ + { .opc = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ + 0xcc, 0xc3, 0xc3, 0xc3 }, /* int3 */ .res.fields.trapnr = TRAP_int3 }, };
Instead of the recurring hex values followed by the /* endbr64 */ comment, how about having a local #define for this? Preferably with such a change
Jan
PATCH 61/65 x86/entry: Make syscall/sysenter entrypoints CET-IBT compatible
In reply to Andrew CooperEach of MSR_{L,C}STAR and MSR_SYSENTER_EIP need to land on an endbr64 instruction. For sysenter, this is easy.
Unfortunately for syscall, the stubs are already 29 byte long with a limit of
32. endbr64 is 4 bytes. Luckily, there is a 1 byte instruction which can move from the stubs into the main handlers.
Move the push %rax out of the stub and into {l,c}star_entry(), allowing room for the endbr64 instruction when appropriate. Update the comment describing the entry state.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/x86_64/entry.S | 18 +++++++++--------- xen/arch/x86/x86_64/traps.c | 13 +++++++++---- 2 files changed, 18 insertions(+), 13 deletions(-)
xen/arch/x86/x86_64/entry.S +9 -9
@@ -241,18 +241,17 @@ iret_exit_to_guest: * When entering SYSCALL from user mode: * Vector directly to the registered arch.syscall_addr. * - * Initial work is done by per-CPU trampolines. At this point %rsp has been - * initialised to point at the correct Xen stack, %rsp has been saved, and - * %rax needs to be restored from the %ss save slot. All other registers are - * still to be saved onto the stack, starting with RFLAGS, and an appropriate - * %ss must be saved into the space left by the trampoline. + * Initial work is done by per-CPU trampolines. + * - Guest %rax stored in the %ss slot + * - Guest %rsp stored in %rax + * - Xen stack loaded, pointing at the %ss slot */ ENTRY(lstar_enter) #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif - /* sti could live here when we don't switch page tables below. */ - movq 8(%rsp),%rax /* Restore %rax. */ + push %rax /* Guest %rsp */ + movq 8(%rsp), %rax /* Restore guest %rax */ movq $FLAT_KERNEL_SS,8(%rsp) pushq %r11 pushq $FLAT_KERNEL_CS64
@@ -288,9 +287,9 @@ ENTRY(cstar_enter) #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif - /* sti could live here when we don't switch page tables below. */ + push %rax /* Guest %rsp */ CR4_PV32_RESTORE - movq 8(%rsp), %rax /* Restore %rax. */ + movq 8(%rsp), %rax /* Restore guest %rax. */ movq $FLAT_USER_SS32, 8(%rsp) /* Assume a 64bit domain. Compat handled lower. */ pushq %r11 pushq $FLAT_USER_CS32
@@ -323,6 +322,7 @@ ENTRY(cstar_enter) jmp switch_to_kernel ENTRY(sysenter_entry) + ENDBR64 #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif
xen/arch/x86/x86_64/traps.c +9 -4
@@ -295,6 +295,15 @@ static unsigned int write_stub_trampoline( {unsigned char *p = stub; +if ( cpu_has_xen_ibt ) + { +/* endbr64 */ + *p++ =0xf3 ; + *p++ =0x0f ; + *p++ =0x1e ; + *p++ =0xfa ; + } +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ *p++ =0x48 ;
@@ -315,10 +324,6 @@ static unsigned int write_stub_trampoline( *(uint64_t *)p = stack_bottom -8 ; p +=8 ; -/* Store guest %rsp into %rsp slot */ -/* pushq %rax */ - *p++ =0x50 ; -/* jmp target_va */ *p++ =0xe9 ; *(int32_t *)p = target_va - (stub_va + (p - stub) +4 );
Signature · 1 line
2.11.0
PATCH 61/65 x86/entry: Make syscall/sysenter entrypoints CET-IBT compatible
In reply to Andrew CooperEach of MSR_{L,C}STAR and MSR_SYSENTER_EIP need to land on an endbr64 instruction. For sysenter, this is easy.
Unfortunately for syscall, the stubs are already 29 byte long with a limit of
32. endbr64 is 4 bytes. Luckily, there is a 1 byte instruction which can move from the stubs into the main handlers.
Move the push %rax out of the stub and into {l,c}star_entry(), allowing room for the endbr64 instruction when appropriate. Update the comment describing the entry state.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
v2:
* Update to use endbr helpers.
--- xen/arch/x86/x86_64/entry.S | 18 +++++++++--------- xen/arch/x86/x86_64/traps.c | 11 +++++++---- 2 files changed, 16 insertions(+), 13 deletions(-)
xen/arch/x86/x86_64/entry.S +9 -9
@@ -241,18 +241,17 @@ iret_exit_to_guest: * When entering SYSCALL from user mode: * Vector directly to the registered arch.syscall_addr. * - * Initial work is done by per-CPU trampolines. At this point %rsp has been - * initialised to point at the correct Xen stack, %rsp has been saved, and - * %rax needs to be restored from the %ss save slot. All other registers are - * still to be saved onto the stack, starting with RFLAGS, and an appropriate - * %ss must be saved into the space left by the trampoline. + * Initial work is done by per-CPU trampolines. + * - Guest %rax stored in the %ss slot + * - Guest %rsp stored in %rax + * - Xen stack loaded, pointing at the %ss slot */ ENTRY(lstar_enter) #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif - /* sti could live here when we don't switch page tables below. */ - movq 8(%rsp),%rax /* Restore %rax. */ + push %rax /* Guest %rsp */ + movq 8(%rsp), %rax /* Restore guest %rax */ movq $FLAT_KERNEL_SS,8(%rsp) pushq %r11 pushq $FLAT_KERNEL_CS64
@@ -288,9 +287,9 @@ ENTRY(cstar_enter) #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif - /* sti could live here when we don't switch page tables below. */ + push %rax /* Guest %rsp */ CR4_PV32_RESTORE - movq 8(%rsp), %rax /* Restore %rax. */ + movq 8(%rsp), %rax /* Restore guest %rax. */ movq $FLAT_USER_SS32, 8(%rsp) /* Assume a 64bit domain. Compat handled lower. */ pushq %r11 pushq $FLAT_USER_CS32
@@ -323,6 +322,7 @@ ENTRY(cstar_enter) jmp switch_to_kernel ENTRY(sysenter_entry) + ENDBR64 #ifdef CONFIG_XEN_SHSTK ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK #endif
xen/arch/x86/x86_64/traps.c +7 -4
@@ -16,6 +16,7 @@#include <asm/current.h> #include <asm/flushtlb.h> #include <asm/traps.h> +#include <asm/endbr.h> #include <asm/event.h> #include <asm/nmi.h> #include <asm/msr.h>
@@ -295,6 +296,12 @@ static unsigned int write_stub_trampoline( {unsigned char *p = stub; +if ( cpu_has_xen_ibt ) + { +place_endbr64 (p); + p +=4 ; + } +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ *p++ =0x48 ;
@@ -315,10 +322,6 @@ static unsigned int write_stub_trampoline( *(uint64_t *)p = stack_bottom -8 ; p +=8 ; -/* Store guest %rsp into %rsp slot */ -/* pushq %rax */ - *p++ =0x50 ; -/* jmp target_va */ *p++ =0xe9 ; *(int32_t *)p = target_va - (stub_va + (p - stub) +4 );
Signature · 1 line
2.11.0
Re: [PATCH v1.1 61/65] x86/entry: Make syscall/sysenter entrypoints CET-IBT compatible
Quoted 6 lines · Andrew Cooper
Each of MSR_{L,C}STAR and
MSR_SYSENTER_EIPneed to land on an endbr64 instruction. For sysenter, this is easy.Unfortunately for syscall, the stubs are already 29 byte long with a limit of
32. endbr64 is 4 bytes. Luckily, there is a 1 byte instruction which can move from the stubs into the main handlers.
Oh, you actually found a different solution to the space problem. I should probably have looked here first, but this being a v1.1 it sits lower in my mailbox ...
Quoted 5 lines
Move the push %rax out of the stub and into {l,c}star_entry(), allowing room for the endbr64 instruction when appropriate. Update the comment describing the entry state.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 14 lines
xen/arch/x86/x86_64/traps.c +6
-0@@ -295,6 +296,12 @@ static unsigned int write_stub_trampoline( {unsigned char *p = stub; +if ( cpu_has_xen_ibt ) + { +place_endbr64 (p); + p +=4 ; + } +/* Store guest %rax into %ss slot */ /* movabsq %rax, stack_bottom - 8 */ *p++ =0x48 ;
xen/arch/x86/x86_64/traps.c static unsigned int write_stub_trampoline( · line 327
Quoted 10 lines
xen/arch/x86/x86_64/traps.c +0
-4@@ -315,10 +322,6 @@ static unsigned int write_stub_trampoline( *(uint64_t *)p = stack_bottom -8 ; p +=8 ; -/* Store guest %rsp into %rsp slot */ -/* pushq %rax */ - *p++ =0x50 ; -/* jmp target_va */ *p++ =0xe9 ; *(int32_t *)p = target_va - (stub_va + (p - stub) +4 );
With this it's even less clear to me why you did remove the 16-byte alignment in the other patch. Initially I expected you would extend the "first half" of stub space by 2 bytes.
Jan
PATCH 62/65 x86/entry: Make IDT entrypoints CET-IBT compatible
In reply to Andrew CooperEach IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/x86_64/compat/entry.S | 1 + xen/arch/x86/x86_64/entry.S | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
xen/arch/x86/x86_64/compat/entry.S +1 -0
@@ -12,6 +12,7 @@ #include <irq_vectors.h> ENTRY(entry_int82) + ENDBR64 ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP pushq $0 movl $HYPERCALL_VECTOR, 4(%rsp)
xen/arch/x86/x86_64/entry.S +26 -2
@@ -386,6 +386,7 @@ UNLIKELY_END(sysenter_gpf) jmp .Lbounce_exception ENTRY(int80_direct_trap) + ENDBR64 ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP pushq $0 movl $0x80, 4(%rsp)
@@ -698,6 +699,7 @@ ENTRY(common_interrupt) jmp ret_from_intr ENTRY(page_fault) + ENDBR64 movl $TRAP_page_fault,4(%rsp) /* No special register assumptions. */ GLOBAL(handle_exception)
@@ -872,75 +874,91 @@ FATAL_exception_with_ints_disabled: BUG /* fatal_trap() shouldn't return. */ ENTRY(divide_error) + ENDBR64 pushq $0 movl $TRAP_divide_error,4(%rsp) jmp handle_exception ENTRY(coprocessor_error) + ENDBR64 pushq $0 movl $TRAP_copro_error,4(%rsp) jmp handle_exception ENTRY(simd_coprocessor_error) + ENDBR64 pushq $0 movl $TRAP_simd_error,4(%rsp) jmp handle_exception ENTRY(device_not_available) + ENDBR64 pushq $0 movl $TRAP_no_device,4(%rsp) jmp handle_exception ENTRY(debug) + ENDBR64 pushq $0 movl $TRAP_debug,4(%rsp) jmp handle_ist_exception ENTRY(int3) + ENDBR64 pushq $0 movl $TRAP_int3,4(%rsp) jmp handle_exception ENTRY(overflow) + ENDBR64 pushq $0 movl $TRAP_overflow,4(%rsp) jmp handle_exception ENTRY(bounds) + ENDBR64 pushq $0 movl $TRAP_bounds,4(%rsp) jmp handle_exception ENTRY(invalid_op) + ENDBR64 pushq $0 movl $TRAP_invalid_op,4(%rsp) jmp handle_exception ENTRY(invalid_TSS) + ENDBR64 movl $TRAP_invalid_tss,4(%rsp) jmp handle_exception ENTRY(segment_not_present) + ENDBR64 movl $TRAP_no_segment,4(%rsp) jmp handle_exception ENTRY(stack_segment) + ENDBR64 movl $TRAP_stack_error,4(%rsp) jmp handle_exception ENTRY(general_protection) + ENDBR64 movl $TRAP_gp_fault,4(%rsp) jmp handle_exception ENTRY(alignment_check) + ENDBR64 movl $TRAP_alignment_check,4(%rsp) jmp handle_exception ENTRY(entry_CP) + ENDBR64 movl $X86_EXC_CP, 4(%rsp) jmp handle_exception ENTRY(double_fault) + ENDBR64 movl $TRAP_double_fault,4(%rsp) /* Set AC to reduce chance of further SMAP faults */ ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
@@ -966,6 +984,7 @@ ENTRY(double_fault) .pushsection .init.text, "ax", @progbits ENTRY(early_page_fault) + ENDBR64 movl $TRAP_page_fault,4(%rsp) SAVE_ALL movq %rsp,%rdi
@@ -974,6 +993,7 @@ ENTRY(early_page_fault) .popsection ENTRY(nmi) + ENDBR64 pushq $0 movl $TRAP_nmi,4(%rsp) handle_ist_exception:
@@ -1102,12 +1122,14 @@ handle_ist_exception: #endif ENTRY(machine_check) + ENDBR64 pushq $0 movl $TRAP_machine_check,4(%rsp) jmp handle_ist_exception /* No op trap handler. Required for kexec crash path. */ GLOBAL(trap_nop) + ENDBR64 iretq /* Table of automatically generated entry points. One per vector. */
@@ -1136,7 +1158,8 @@ autogen_stubs: /* Automatically generated stubs. */ #endif ALIGN -1: pushq $0 +1: ENDBR64 + pushq $0 movb $vec,4(%rsp) jmp common_interrupt
@@ -1146,7 +1169,8 @@ autogen_stubs: /* Automatically generated stubs. */ .elseif vec == X86_EXC_CSO || vec == X86_EXC_SPV || \ vec == X86_EXC_VE || (vec > X86_EXC_CP && vec < TRAP_nr) -1: test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ +1: ENDBR64 + test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ jz 2f /* size is 8 bytes. Check whether the processor gave us an */ pushq $0 /* error code, and insert an empty one if not. */ 2: movb $vec,4(%rsp)
Signature · 1 line
2.11.0
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 5 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
Signed-off-by Andrew Cooper <[email protected]>
One remark though:
Quoted 11 lines
xen/arch/x86/x86_64/entry.S +2
-1@@ -1136,7 +1158,8 @@ autogen_stubs: /* Automatically generated stubs. */ #endif ALIGN -1: pushq $0 +1: ENDBR64 + pushq $0 movb $vec,4(%rsp) jmp common_interrupt
xen/arch/x86/x86_64/entry.S autogen_stubs: /* Automatically generated stubs. */ · line 1176
Quoted 9 lines
xen/arch/x86/x86_64/entry.S +2
-1@@ -1146,7 +1169,8 @@ autogen_stubs: /* Automatically generated stubs. */ .elseif vec == X86_EXC_CSO || vec == X86_EXC_SPV || \ vec == X86_EXC_VE || (vec > X86_EXC_CP && vec < TRAP_nr) -1: test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ +1: ENDBR64 + test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ jz 2f /* size is 8 bytes. Check whether the processor gave us an */ pushq $0 /* error code, and insert an empty one if not. */ 2: movb $vec,4(%rsp)
Like with initializers of compound objects vs trailing commas there, I think it would help if we moved away from placing insns on the same lines as labels. As can be seen here, inserting something always means touching two lines instead of just adding one.
Jan
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 7 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
Quoted 17 lines
One remark though:
Quoted 14 lines
xen/arch/x86/x86_64/entry.S +2
-1@@ -1136,7 +1158,8 @@ autogen_stubs: /* Automatically generated stubs. */ #endif ALIGN -1: pushq $0 +1: ENDBR64 + pushq $0 movb $vec,4(%rsp) jmp common_interrupt@@ -1146,7 +1169,8 @@ autogen_stubs: /* Automatically generated stubs. */ .elseif vec == X86_EXC_CSO || vec == X86_EXC_SPV || \ vec == X86_EXC_VE || (vec > X86_EXC_CP && vec < TRAP_nr)
Quoted 10 lines
xen/arch/x86/x86_64/entry.S autogen_stubs: /* Automatically generated stubs. */ · line 1176
Quoted 6 lines
xen/arch/x86/x86_64/entry.S +2
-1-1: test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ +1: ENDBR64 + test $8,%spl /* 64bit exception frames are 16 byte aligned, but the word */ jz 2f /* size is 8 bytes. Check whether the processor gave us an */ pushq $0 /* error code, and insert an empty one if not. */ 2: movb $vec,4(%rsp)Like with initializers of compound objects vs trailing commas there, I think it would help if we moved away from placing insns on the same lines as labels. As can be seen here, inserting something always means touching two lines instead of just adding one.
I had actually wondered the same, without drawing a comparison to trailing commas. I'll adjust.
~Andrew
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
In reply to Andrew CooperQuoted 3 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
One question here: How does this work? I don't recall there being any "CET shadow" along the lines of "STI shadow" and "SS shadow", yet there's clearly an insn boundary here that gets "skipped" if the 2nd #CP gets converted to #DF. And fetching of the first handler insn also isn't part of exception delivery (and could cause other exceptions first, like #PF).
Jan
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
One question here: How does this work?
Honestly, I'm not sure.
Quoted 5 lines
I don't recall there being any "CET
shadow" along the lines of "STI shadow" and "SS shadow", yet there's clearly an insn boundary here that gets "skipped" if the 2nd #CP gets converted to #DF. And fetching of the first handler insn also isn't part of exception delivery (and could cause other exceptions first, like #PF).
I can't make my observations of real hardware behaviour match the description in the spec.
Given what a mess it all is, I wouldn't be surprised if the exception delivery microcode has a special case to escalate this to #DF.
If it didn't escalate to #DF, then you'd end up with an infinite stream of #CP's, which will most likely cause a stack overflow because #CP needs to be not-IST for shadow stack reasons.
~Andrew
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 9 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
One question here: How does this work?
Honestly, I'm not sure.
Quoted 8 lines
Quoted 5 lines
I don't recall there being any "CET
shadow" along the lines of "STI shadow" and "SS shadow", yet there's clearly an insn boundary here that gets "skipped" if the 2nd #CP gets converted to #DF. And fetching of the first handler insn also isn't part of exception delivery (and could cause other exceptions first, like #PF).I can't make my observations of real hardware behaviour match the description in the spec.
I haven't been able to find a description at all of exception behavior when the exception occurs in wait-for-endbr state. There is text saying that #BP and #DB can occur this way, but I couldn't find anything about the tracker state changes in such cases. While I could see the state to remain engaged (requiring an ENDBR at the handler's entry point), I cannot see how the state would get re-engaged upon IRET from the exception handler, unless the return is back to CPL3.
Quoted 2 lines
Given what a mess it all is, I wouldn't be surprised if the exception delivery microcode has a special case to escalate this to #DF.
I am meanwhile wondering whether any exception in wait-for-endbr state at CPL < 3 would promote to #DF, for loss of state. Albeit there must still be a distinction between CALL/JMP induced state and that resulting from interrupt or exception delivery. Yet there's no architectural (or shadow) state expressing "first insn of an exception handler".
I'm not even convinced the aforementioned statements about #DB and #BP are actually meant to cover more than just CPL3, or at best ENDBR at normal CALL/JMP destinations.
While for Xen's own use we may get away without knowing how all of this actually works (perhaps accepting the fact that one can't set breakpoints at exception handler entry points, depending on whether their delivery would promote to #DF), as soon as we were to support CET-IBT for guests we'd definitely need to know.
Jan
Quoted 6 lines
If it didn't escalate to #DF, then you'd end up with an infinite stream of #CP's, which will most likely cause a stack overflow because #CP needs to be not-IST for shadow stack reasons.
~Andrew
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 16 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
One question here: How does this work?
Honestly, I'm not sure.
Quoted 7 lines
Quoted 5 lines
I don't recall there being any "CET
shadow" along the lines of "STI shadow" and "SS shadow", yet there's clearly an insn boundary here that gets "skipped" if the 2nd #CP gets converted to #DF. And fetching of the first handler insn also isn't part of exception delivery (and could cause other exceptions first, like #PF).I can't make my observations of real hardware behaviour match the description in the spec.
Quoted 7 lines
I haven't been able to find a description at all of exception behavior when the exception occurs in wait-for-endbr state. There is text saying that #BP and #DB can occur this way, but I couldn't find anything about the tracker state changes in such cases. While I could see the state to remain engaged (requiring an ENDBR at the handler's entry point), I cannot see how the state would get re-engaged upon IRET from the exception handler, unless the return is back to CPL3.
Critically, there are two wait-for-endbr states. One in MSR_U_CET and one in MSR_S_CET, and the active one is dependent on CPL.
Interrupting CPL3 does leave the state visible (and frozen) in MSR_U_CET.
Interrupting CPL!=0 does not. The interrupt/exception delivery microcode forces the wait-for-endbr state which is why the entrypoints need ENDBR64, and while I haven't confirmed yet, I'm pretty certain that a WRMSR to MSR_S_CET which sets wait-for-endbr needs an ENDBR64 following it.
IRET does not alter the wait-for-endbr state, but does switch which of the two trackers is active, as a side effect of changing CPL.
#CP is a decode-class fault, and takes priority over #UD and #NM. However, the #BP/#DB special cases are specific to the INT3/INT1 instructions, to specifically permit putting a breakpoint on an ENDBR instruction and to take the breakpoint exception rather than #CP. Critically, #CP has higher priority than General Detect #DB.
(I've already got the beginnings of an XTF test case for shstk corner cases, but it's got nothing on how complicated the IBT side of things looks.)
Quoted 8 lines
Quoted 2 lines
Given what a mess it all is, I wouldn't be surprised if the exception delivery microcode has a special case to escalate this to #DF.
I am meanwhile wondering whether any exception in wait-for-endbr state at CPL < 3 would promote to #DF, for loss of state. Albeit there must still be a distinction between CALL/JMP induced state and that resulting from interrupt or exception delivery. Yet there's no architectural (or shadow) state expressing "first insn of an exception handler".
Architecturally, no, but there is internally by virtue of the fact that all interrupt/exception delivery is organised by microcode.
Quoted 9 lines
I'm not even convinced the aforementioned statements about #DB and #BP are actually meant to cover more than just CPL3, or at best ENDBR at normal CALL/JMP destinations.
While for Xen's own use we may get away without knowing how all of this actually works (perhaps accepting the fact that one can't set breakpoints at exception handler entry points, depending on whether their delivery would promote to #DF), as soon as we were to support CET-IBT for guests we'd definitely need to know.
I'm afraid I don't follow the point you're trying to make. INT3/INT1 are explicitly special, to let you breakpoint an ENDBR instruction, and that really ought to mean everywhere.
Another possibility is that my observations are an errata in TGL, or that I've made a mistake somewhere.
However, until we start getting to the point of having some real XTF tests for behaviour, including that of the emulator, I doubt we'll get much clarity. Furthermore, there's a pile of work to do before that is a possibility. As a minimum, I need to fix up and repost my xsave cleanup series, then implement XSAVES support for guests, before we can make CET an opt-in feature pending completion of the emulation work.
~Andrew
Re: [PATCH 62/65] x86/entry: Make IDT entrypoints CET-IBT compatible
Quoted 28 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
Each IDT vector needs to land on an endbr64 instruction. This is especially important for the #CP handler, which will escalate to #DF if the endbr64 is missing.
One question here: How does this work?
Honestly, I'm not sure.
Quoted 7 lines
Quoted 5 lines
I don't recall there being any "CET
shadow" along the lines of "STI shadow" and "SS shadow", yet there's clearly an insn boundary here that gets "skipped" if the 2nd #CP gets converted to #DF. And fetching of the first handler insn also isn't part of exception delivery (and could cause other exceptions first, like #PF).I can't make my observations of real hardware behaviour match the description in the spec.
Quoted 7 lines
I haven't been able to find a description at all of exception behavior when the exception occurs in wait-for-endbr state. There is text saying that #BP and #DB can occur this way, but I couldn't find anything about the tracker state changes in such cases. While I could see the state to remain engaged (requiring an ENDBR at the handler's entry point), I cannot see how the state would get re-engaged upon IRET from the exception handler, unless the return is back to CPL3.
Critically, there are two wait-for-endbr states. One in
MSR_U_CETand one inMSR_S_CET, and the active one is dependent on CPL.
Quoted 7 lines
Interrupting CPL3 does leave the state visible (and frozen) in
MSR_U_CET.Interrupting CPL!=0 does not. The interrupt/exception delivery microcode forces the wait-for-endbr state which is why the entrypoints need ENDBR64, and while I haven't confirmed yet, I'm pretty certain that a WRMSR to
MSR_S_CETwhich sets wait-for-endbr needs an ENDBR64 following it.
That's my expectation, too.
Quoted 2 lines
IRET does not alter the wait-for-endbr state, but does switch which of the two trackers is active, as a side effect of changing CPL.
Well, it only really _switches_ when going from CPL<3 to CPL3. Otherwise it leaves what is there, meaning wait-for-endbr disengaged. And hence an interruption at the target of an indirect CALL/JMP will squash the requirement for an ENDBR to be there. Perhaps a weakness that the architects considered acceptable and "better" than having to add a way to save/restore state (where at least the restore part would necessarily need to be part of IRET itself).
Quoted 5 lines
#CP is a decode-class fault, and takes priority over #UD and #NM. However, the #BP/#DB special cases are specific to the INT3/INT1 instructions, to specifically permit putting a breakpoint on an ENDBR instruction and to take the breakpoint exception rather than #CP. Critically, #CP has higher priority than General Detect #DB.
That's what the text in the spec suggests. Yet why would #DB / #BP be any more special / important than, say, #PF?
Quoted 22 lines
Quoted 8 lines
Quoted 2 lines
Given what a mess it all is, I wouldn't be surprised if the exception delivery microcode has a special case to escalate this to #DF.
I am meanwhile wondering whether any exception in wait-for-endbr state at CPL < 3 would promote to #DF, for loss of state. Albeit there must still be a distinction between CALL/JMP induced state and that resulting from interrupt or exception delivery. Yet there's no architectural (or shadow) state expressing "first insn of an exception handler".
Architecturally, no, but there is internally by virtue of the fact that all interrupt/exception delivery is organised by microcode.
Quoted 9 lines
I'm not even convinced the aforementioned statements about #DB and #BP are actually meant to cover more than just CPL3, or at best ENDBR at normal CALL/JMP destinations.
While for Xen's own use we may get away without knowing how all of this actually works (perhaps accepting the fact that one can't set breakpoints at exception handler entry points, depending on whether their delivery would promote to #DF), as soon as we were to support CET-IBT for guests we'd definitely need to know.
Quoted 3 lines
I'm afraid I don't follow the point you're trying to make. INT3/INT1 are explicitly special, to let you breakpoint an ENDBR instruction, and that really ought to mean everywhere.
Maybe. The point I was trying to make was the more general case of an exception of the ENDBR at the beginning of another exception handler. Perhaps there indeed is merely a special case for #CP. But that wouldn't help with e.g. #PF occurring on the #CP handler entry point and the #PF handler lacking ENDBR. How these cases are meant to work (and which ones have special treatment) is necessary for us to know the latest when we want to allow guests to use the features. There, besides getting things to function correctly, it would also be relevant to know to be sure there's no XSA-156 equivalent lurking.
Jan
PATCH 63/65 x86/setup: Rework MSR_S_CET handling for CET-IBT
In reply to Andrew CooperCET-SS and CET-IBT can be independently controlled, so the configuration of MSR_S_CET can't be constants any more.
Introduce xen_msr_s_cet_value(), mostly because I don't fancy writing/maintaining that logic in assembly. Use this in the 3 paths which alter MSR_S_CET when both features are potentially active.
To active CET-IBT, we only need CR4.CET and MSR_S_CET.ENDBR_EN. This is common with the CET-SS setup, so reorder the operations to set up CR4 and MSR_S_CET for any nonzero result from xen_msr_s_cet_value(), and set up MSR_PL0_SSP and SSP if SHSTK_EN was also set.
Adjust the crash path to disable CET-IBT too.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
It is quite possible that the S3 path is dead code. CET-IBT only exist on Intel systems from TigerLake onwards, and TGL kills S3 in favour of the newer S0ix power state.
AMD Ryzen platforms (Zen3 onwards) support S3 and CET-SS, so partial testing will occur there.
--- xen/arch/x86/acpi/wakeup_prot.S | 37 ++++++++++++++++++++++--------------- xen/arch/x86/boot/x86_64.S | 29 ++++++++++++++++++----------- xen/arch/x86/crash.c | 4 ++-- xen/arch/x86/setup.c | 17 ++++++++++++++++- xen/include/asm-x86/msr-index.h | 1 + 5 files changed, 59 insertions(+), 29 deletions(-)
xen/arch/x86/acpi/wakeup_prot.S +22 -15
@@ -63,7 +63,24 @@ ENTRY(s3_resume) pushq %rax lretq 1: -#ifdef CONFIG_XEN_SHSTK +#if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT) + call xen_msr_s_cet_value + test %eax, %eax + je .L_cet_done + + /* Set up MSR_S_CET. */ + mov $MSR_S_CET, %ecx + xor %edx, %edx + wrmsr + + /* Enable CR4.CET. */ + mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx + mov %rcx, %cr4 + +#if defined(CONFIG_XEN_SHSTK) + test $CET_SHSTK_EN, %eax + je .L_cet_done + /* * Restoring SSP is a little complicated, because we are intercepting * an in-use shadow stack. Write a temporary token under the stack,
@@ -71,14 +88,6 @@ ENTRY(s3_resume) * reset MSR_PL0_SSP to its usual value and pop the temporary token. */ mov saved_ssp(%rip), %rdi - cmpq $1, %rdi - je .L_shstk_done - - /* Set up MSR_S_CET. */ - mov $MSR_S_CET, %ecx - xor %edx, %edx - mov $CET_SHSTK_EN | CET_WRSS_EN, %eax - wrmsr /* Construct the temporary supervisor token under SSP. */ sub $8, %rdi
@@ -90,12 +99,9 @@ ENTRY(s3_resume) mov %edi, %eax wrmsr - /* Enable CET. MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ - mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ebx - mov %rbx, %cr4 - /* Write the temporary token onto the shadow stack, and activate it. */ wrssq %rdi, (%rdi) + /* MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ setssbsy /* Reset MSR_PL0_SSP back to its normal value. */
@@ -106,8 +112,9 @@ ENTRY(s3_resume) /* Pop the temporary token off the stack. */ mov $2, %eax incsspd %eax -.L_shstk_done: -#endif +#endif /* CONFIG_XEN_SHSTK */ +.L_cet_done: +#endif /* CONFIG_XEN_SHSTK || CONFIG_XEN_IBT */ call load_system_tables
xen/arch/x86/boot/x86_64.S +18 -11
@@ -30,18 +30,25 @@ ENTRY(__high_start) test %ebx,%ebx jz .L_bsp - /* APs. Set up shadow stacks before entering C. */ -#ifdef CONFIG_XEN_SHSTK - testl $cpufeat_mask(X86_FEATURE_XEN_SHSTK), \ - CPUINFO_FEATURE_OFFSET(X86_FEATURE_XEN_SHSTK) + boot_cpu_data(%rip) - je .L_ap_shstk_done + /* APs. Set up CET before entering C properly. */ +#if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT) + call xen_msr_s_cet_value + test %eax, %eax + je .L_ap_cet_done /* Set up MSR_S_CET. */ mov $MSR_S_CET, %ecx xor %edx, %edx - mov $CET_SHSTK_EN | CET_WRSS_EN, %eax wrmsr + /* Enable CR4.CET. */ + mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx + mov %rcx, %cr4 + +#if defined(CONFIG_XEN_SHSTK) + test $CET_SHSTK_EN, %eax + je .L_ap_cet_done + /* Derive MSR_PL0_SSP from %rsp (token written when stack is allocated). */ mov $MSR_PL0_SSP, %ecx mov %rsp, %rdx
@@ -51,13 +58,13 @@ ENTRY(__high_start) or $(PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8, %eax wrmsr - /* Enable CET. MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ - mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx - mov %rcx, %cr4 + /* MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ setssbsy -#endif -.L_ap_shstk_done: +#endif /* CONFIG_XEN_SHSTK */ +.L_ap_cet_done: +#endif /* CONFIG_XEN_SHSTK || CONFIG_XEN_IBT */ + call start_secondary BUG /* start_secondary() shouldn't return. */
xen/arch/x86/crash.c +2 -2
@@ -190,8 +190,8 @@ void machine_crash_shutdown(void)/* Reset CPUID masking and faulting to the host's default. */ ctxt_switch_levelling (NULL ); -/* Disable shadow stacks. */ -if ( cpu_has_xen_shstk ) +/* Disable CET. */ +if ( cpu_has_xen_shstk || cpu_has_xen_ibt ) {wrmsrl (MSR_S_CET ,0 );write_cr4 (read_cr4 () & ~X86_CR4_CET );
xen/arch/x86/setup.c +16 -1
@@ -661,6 +661,21 @@ static void noreturn init_done(void)startup_cpu_idle_loop (); } +#if defined(CONFIG_XEN_SHSTK ) || defined(CONFIG_XEN_IBT ) +/* +* Used by AP and S3 asm code to calcualte the appropriate MSR_S_CET setting. +* Do not use on the BSP before reinit_bsp_stack(), or it may turn SHSTK on +* too early. +*/ +unsigned int xen_msr_s_cet_value (void ) +{ +return ((cpu_has_xen_shstk ?CET_SHSTK_EN |CET_WRSS_EN :0 ) | + (cpu_has_xen_ibt ?CET_ENDBR_EN :0 )); +} +#else +unsigned int xen_msr_s_cet_value (void );/* To avoid ifdefary */ +#endif +/* Reinitalise all state referring to the old virtual address of the stack. */ static void __init noreturnreinit_bsp_stack (void ) {
@@ -684,7 +699,7 @@ static void __init noreturn reinit_bsp_stack(void) {wrmsrl (MSR_PL0_SSP , (unsigned long )stack + (PRIMARY_SHSTK_SLOT +1 ) *PAGE_SIZE -8 ); -wrmsrl (MSR_S_CET ,CET_SHSTK_EN |CET_WRSS_EN ); +wrmsrl (MSR_S_CET ,xen_msr_s_cet_value ()); asmvolatile ("setssbsy" :::"memory" ); }
xen/include/asm-x86/msr-index.h +1 -0
@@ -115,6 +115,7 @@#define MSR_S_CET 0x000006a2#define CET_SHSTK_EN (_AC(1, ULL) << 0)#define CET_WRSS_EN (_AC(1, ULL) << 1) +#define CET_ENDBR_EN (_AC(1, ULL) << 2)#define MSR_PL0_SSP 0x000006a4#define MSR_PL1_SSP 0x000006a5
Signature · 1 line
2.11.0
Re: [PATCH 63/65] x86/setup: Rework MSR_S_CET handling for CET-IBT
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 69
Quoted 11 lines · Andrew Cooper
xen/arch/x86/acpi/wakeup_prot.S +4
-1@@ -63,7 +63,24 @@ ENTRY(s3_resume) pushq %rax lretq 1: -#ifdef CONFIG_XEN_SHSTK +#if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT) + call xen_msr_s_cet_value + test %eax, %eax + je .L_cet_done
Nit: I consider it generally misleading to use JE / JNE (and a few other Jcc) with other than CMP-like insns. Only those handle actual "relations", whereas e.g. TEST only produces particular flag states, so would more consistently be followed by JZ / JNZ in cases like this one. But since this is very much a matter of taste, I'm not going to insist on a change here.
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 78
Quoted 8 lines
xen/arch/x86/acpi/wakeup_prot.S +8
-0+ /* Set up MSR_S_CET. */ + mov $MSR_S_CET, %ecx + xor %edx, %edx + wrmsr + + /* Enable CR4.CET. */ + mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx + mov %rcx, %cr4
Is it valid / safe to enable CR4.CET (with CET_SHSTK_EN already active) before ...
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 79
Quoted 2 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-0+#if defined(CONFIG_XEN_SHSTK) + test $CET_SHSTK_EN, %eax
(Intermediate remark: Using %al would seem to suffice and be a shorter encoding.)
Quoted 21 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-8+ je .L_cet_done + /* * Restoring SSP is a little complicated, because we are intercepting * an in-use shadow stack. Write a temporary token under the stack,@@ -71,14 +88,6 @@ ENTRY(s3_resume) * reset MSR_PL0_SSP to its usual value and pop the temporary token. */ mov saved_ssp(%rip), %rdi - cmpq $1, %rdi - je .L_shstk_done - - /* Set up MSR_S_CET. */ - mov $MSR_S_CET, %ecx - xor %edx, %edx - mov $CET_SHSTK_EN | CET_WRSS_EN, %eax - wrmsr /* Construct the temporary supervisor token under SSP. */ sub $8, %rdi
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 95
Quoted 6 lines
xen/arch/x86/acpi/wakeup_prot.S +0
-3@@ -90,12 +99,9 @@ ENTRY(s3_resume) mov %edi, %eax wrmsr - /* Enable CET. MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ - mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ebx - mov %rbx, %cr4
... the writing of MSR_PL0_SSP in context here? ISTR some ordering issues back at the time when you introduced CET-SS, so I thought I'd better ask to be sure.
Jan
Re: [PATCH 63/65] x86/setup: Rework MSR_S_CET handling for CET-IBT
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Andrew Cooper
xen/arch/x86/acpi/wakeup_prot.S +2
-1@@ -63,7 +63,24 @@ ENTRY(s3_resume) pushq %rax lretq 1: -#ifdef CONFIG_XEN_SHSTK +#if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT) + call xen_msr_s_cet_value
Quoted 8 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 69
Quoted 2 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-0+ test %eax, %eax + je .L_cet_doneNit: I consider it generally misleading to use JE / JNE (and a few other Jcc) with other than CMP-like insns. Only those handle actual "relations", whereas e.g. TEST only produces particular flag states, so would more consistently be followed by JZ / JNZ in cases like this one. But since this is very much a matter of taste, I'm not going to insist on a change here.
Fixed.
Quoted 9 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 77
Quoted 9 lines
xen/arch/x86/acpi/wakeup_prot.S +8
-0+ /* Set up MSR_S_CET. */ + mov $MSR_S_CET, %ecx + xor %edx, %edx + wrmsr + + /* Enable CR4.CET. */ + mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx + mov %rcx, %cr4
Quoted 7 lines
Is it valid / safe to enable CR4.CET (with
CET_SHSTK_ENalready active) before ...xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 79
Quoted 2 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-0+#if defined(CONFIG_XEN_SHSTK) + test $CET_SHSTK_EN, %eax(Intermediate remark: Using %al would seem to suffice and be a shorter encoding.)
Fixed.
Quoted 25 lines
Quoted 25 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-8+ je .L_cet_done + /* * Restoring SSP is a little complicated, because we are intercepting * an in-use shadow stack. Write a temporary token under the stack,@@ -71,14 +88,6 @@ ENTRY(s3_resume) * reset MSR_PL0_SSP to its usual value and pop the temporary token. */ mov saved_ssp(%rip), %rdi - cmpq $1, %rdi - je .L_shstk_done - - /* Set up MSR_S_CET. */ - mov $MSR_S_CET, %ecx - xor %edx, %edx - mov $CET_SHSTK_EN | CET_WRSS_EN, %eax - wrmsr /* Construct the temporary supervisor token under SSP. */ sub $8, %rdi@@ -90,12 +99,9 @@ ENTRY(s3_resume) mov %edi, %eax wrmsr
Quoted 6 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 95
Quoted 3 lines
xen/arch/x86/acpi/wakeup_prot.S +0
-3- /* Enable CET. MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ - mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ebx - mov %rbx, %cr4... the writing of
MSR_PL0_SSPin context here? ISTR some ordering issues back at the time when you introduced CET-SS, so I thought I'd better ask to be sure.
Yes, it is safe, but the reasons why aren't entirely trivial.
To set up CET-SS, we need to do the following things:
1) CR4.CET=1
2) Configure MSR_S_CET.SHSTK_EN
3) Configure MSR_PL0_SSP pointing at a non-busy supervisor token
4) Configure MSR_ISST_SSP to point at the IST shadow stacks, again with non-busy tokens
5) execute SETSSBSY to load SSP
The MSRs can be configured whenever, subject to suitable hardware support. In both of these cases, we've actually pre-configured the non-busy supervisor tokens which is why we don't set those up directly.
Furthermore, we defer setting up MSR_ISST_SSP to when we set up the IDT and TSS, and that's fine because it doesn't make interrupts/exceptions any less fatal.
The only hard ordering is that SETSSBSY depends on CR4.CET && MSR_S_CET.SHSTK_EN in order to not #UD.
However, between CR4.CET && MSR_S_CET.SHSTK_EN and SETSSBSY, we're operating with an SSP of 0, meaning that any call/ret/etc are fatal. That is why I previously grouped the 3 actions as close to together as possible.
For the CONFIG_XEN_IBT && !CONFIG_XEN_SHSTK case, we need to set up CR4 and MSR_S_CET only. This was the only way I could find to lay out the logic in a half-reasonable way. It does mean that MSR_PL0_SSP is set up during the critical call/ret region, but that's the smallest price I could find to pay. Anything else would have had more conditionals, and substantially more #ifdef-ary.
I have put in this:
xen/arch/x86/boot/x86_64.S +0 -0
@@ -45,6 +45,8 @@ ENTRY(__high_start)
mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx
mov %rcx, %cr4
+ /* WARNING! call/ret/etc now fatal (iff SHSTK) until SETSSBSY loads SSP */
+
#if defined(CONFIG_XEN_SHSTK)
test $CET_SHSTK_EN, %al
jz .L_ap_cet_done
which mirrors our Spectre-v2 warning in the entry paths.
~Andrew
Re: [PATCH 63/65] x86/setup: Rework MSR_S_CET handling for CET-IBT
Quoted 126 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Andrew Cooper
xen/arch/x86/acpi/wakeup_prot.S +2
-1@@ -63,7 +63,24 @@ ENTRY(s3_resume) pushq %rax lretq 1: -#ifdef CONFIG_XEN_SHSTK +#if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT) + call xen_msr_s_cet_valueQuoted 8 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 69
Quoted 2 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-0+ test %eax, %eax + je .L_cet_doneNit: I consider it generally misleading to use JE / JNE (and a few other Jcc) with other than CMP-like insns. Only those handle actual "relations", whereas e.g. TEST only produces particular flag states, so would more consistently be followed by JZ / JNZ in cases like this one. But since this is very much a matter of taste, I'm not going to insist on a change here.
Fixed.
Quoted 9 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 77
Quoted 9 lines
xen/arch/x86/acpi/wakeup_prot.S +8
-0+ /* Set up MSR_S_CET. */ + mov $MSR_S_CET, %ecx + xor %edx, %edx + wrmsr + + /* Enable CR4.CET. */ + mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx + mov %rcx, %cr4Quoted 7 lines
Is it valid / safe to enable CR4.CET (with
CET_SHSTK_ENalready active) before ...xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 79
Quoted 2 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-0+#if defined(CONFIG_XEN_SHSTK) + test $CET_SHSTK_EN, %eax(Intermediate remark: Using %al would seem to suffice and be a shorter encoding.)
Fixed.
Quoted 25 lines
Quoted 25 lines
xen/arch/x86/acpi/wakeup_prot.S +2
-8+ je .L_cet_done + /* * Restoring SSP is a little complicated, because we are intercepting * an in-use shadow stack. Write a temporary token under the stack,@@ -71,14 +88,6 @@ ENTRY(s3_resume) * reset MSR_PL0_SSP to its usual value and pop the temporary token. */ mov saved_ssp(%rip), %rdi - cmpq $1, %rdi - je .L_shstk_done - - /* Set up MSR_S_CET. */ - mov $MSR_S_CET, %ecx - xor %edx, %edx - mov $CET_SHSTK_EN | CET_WRSS_EN, %eax - wrmsr /* Construct the temporary supervisor token under SSP. */ sub $8, %rdi@@ -90,12 +99,9 @@ ENTRY(s3_resume) mov %edi, %eax wrmsrQuoted 6 lines
xen/arch/x86/acpi/wakeup_prot.S ENTRY(s3_resume) · line 95
Quoted 3 lines
xen/arch/x86/acpi/wakeup_prot.S +0
-3- /* Enable CET. MSR_INTERRUPT_SSP_TABLE is set up later in load_system_tables(). */ - mov $XEN_MINIMAL_CR4 | X86_CR4_CET, %ebx - mov %rbx, %cr4... the writing of
MSR_PL0_SSPin context here? ISTR some ordering issues back at the time when you introduced CET-SS, so I thought I'd better ask to be sure.Yes, it is safe, but the reasons why aren't entirely trivial.
To set up CET-SS, we need to do the following things:
1) CR4.CET=1
2) Configure MSR_S_CET.SHSTK_EN
3) ConfigureMSR_PL0_SSPpointing at a non-busy supervisor token
4) ConfigureMSR_ISST_SSPto point at the IST shadow stacks, again with non-busy tokens
5) execute SETSSBSY to load SSPThe MSRs can be configured whenever, subject to suitable hardware support. In both of these cases, we've actually pre-configured the non-busy supervisor tokens which is why we don't set those up directly.
Furthermore, we defer setting up
MSR_ISST_SSPto when we set up the IDT and TSS, and that's fine because it doesn't make interrupts/exceptions any less fatal.The only hard ordering is that SETSSBSY depends on CR4.CET && MSR_S_CET.SHSTK_EN in order to not #UD.
However, between CR4.CET && MSR_S_CET.SHSTK_EN and SETSSBSY, we're operating with an SSP of 0, meaning that any call/ret/etc are fatal. That is why I previously grouped the 3 actions as close to together as possible.
For the
CONFIG_XEN_IBT&& !CONFIG_XEN_SHSTK case, we need to set up CR4 andMSR_S_CETonly. This was the only way I could find to lay out the logic in a half-reasonable way. It does mean thatMSR_PL0_SSPis set up during the critical call/ret region, but that's the smallest price I could find to pay. Anything else would have had more conditionals, and substantially more #ifdef-ary.I have put in this:
xen/arch/x86/boot/x86_64.S +0
-0@@ -45,6 +45,8 @@ ENTRY(__high_start)mov $XEN_MINIMAL_CR4 |
X86_CR4_CET, %ecx
mov %rcx, %cr4
+ /* WARNING! call/ret/etc now fatal (iff SHSTK) until SETSSBSY loads SSP */
+
#ifdefined(CONFIG_XEN_SHSTK)
test $CET_SHSTK_EN, %al
jz .L_ap_cet_done
Quoted 1 line
which mirrors our Spectre-v2 warning in the entry paths.
Thanks, I think this may end up helpful down the road.
Jan
PATCH 1/1 x86: Introduce helpers/checks for endbr64 instructions
In reply to Andrew Cooper... to prevent the optimiser creating unsafe code. See the code comment for full details.
Also add a build time check for endbr64 embedded in imm32 operands, which catches the obvious cases where the optimiser has done an unsafe thing.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/Makefile | 4 ++++ xen/include/asm-x86/endbr.h | 55 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/include/asm-x86/endbr.h
xen/arch/x86/Makefile +4 -0
@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || : +endif $(NM) -pa --format=sysv $(@D)/$(@F) \ | $(BASEDIR)/tools/symbols --all-symbols --xensyms --sysv --sort \ >$(@D)/$(@F).map
xen/include/asm-x86/endbr.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 59.5/65] x86: Introduce helpers/checks for endbr64 instructions
Quoted 22 lines · Andrew Cooper
... to prevent the optimiser creating unsafe code. See the code comment for full details.
Also add a build time check for endbr64 embedded in imm32 operands, which catches the obvious cases where the optimiser has done an unsafe thing.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>--- xen/arch/x86/Makefile | 4 ++++ xen/include/asm-x86/endbr.h | 55 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/include/asm-x86/endbr.hxen/arch/x86/Makefile +0
-0
xen/arch/x86/Makefile $(TARGET)-syms: prelink.o xen.lds · line 196
Quoted 7 lines
xen/arch/x86/Makefile +4
-0@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || : +endif
Some more robust check can be done this way (warning, PoC quality bash):
objcopy -j .text xen-syms xen-syms.text
offset=$(objdump -h xen-syms -j .text | tail -2|head -1|awk '{printf "%x\n", (strtonum("0x" $4) - strtonum("0x" $6))}')
objdump --adjust-vma=-0x$offset -d xen-syms.text|grep endbr | cut -f 1 -d ':' | tr -d ' ' > valid-addrs
grep -aob $'\xf3\x0f\x1e\xfa' xen-syms.text|cut -f 1 -d :|xargs printf '%x\n' > all-addrs
join -v 2 <(sort valid-addrs) <(sort all-addrs) | awk '{ printf "%x\n", 0x'$offset' + strtonum("0x" $1)}' | addr2line -e xen-symsCurrently it finds just one match:xen/arch/x86/alternative.c:145
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [PATCH 59.5/65] x86: Introduce helpers/checks for endbr64 instructions
Quoted 32 lines · Marek Marczykowski-Górecki
Quoted 22 lines · Andrew Cooper
... to prevent the optimiser creating unsafe code. See the code comment for full details.
Also add a build time check for endbr64 embedded in imm32 operands, which catches the obvious cases where the optimiser has done an unsafe thing.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>--- xen/arch/x86/Makefile | 4 ++++ xen/include/asm-x86/endbr.h | 55 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/include/asm-x86/endbr.hxen/arch/x86/Makefile +0
-0xen/arch/x86/Makefile $(TARGET)-syms: prelink.o xen.lds · line 196
Quoted 7 lines
xen/arch/x86/Makefile +4
-0@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || : +endifSome more robust check can be done this way (warning, PoC quality bash):
Quoted 8 lines
objcopy -j .text xen-syms xen-syms.text offset=$(objdump -h xen-syms -j .text | tail -2|head -1|awk '{printf "%x\n", (strtonum("0x" $4) - strtonum("0x" $6))}') objdump --adjust-vma=-0x$offset -d xen-syms.text|grep endbr | cut -f 1 -d ':' | tr -d ' ' > valid-addrs grep -aob $'\xf3\x0f\x1e\xfa' xen-syms.text|cut -f 1 -d :|xargs printf '%x\n' > all-addrs join -v 2 <(sort valid-addrs) <(sort all-addrs) | awk '{ printf "%x\n", 0x'$offset' + strtonum("0x" $1)}' | addr2line -e xen-symsCurrently it finds just one match:
xen/arch/x86/alternative.c:145
To be clear, this one match is on the xen-cet-ibt v1.1 branch, which also includes the next task (runtime clobbering of unused ENDBR instructions) which I'm currently cleaning up to post.
~Andrew
Re: [PATCH 59.5/65] x86: Introduce helpers/checks for endbr64 instructions
In reply to Andrew CooperQuoted 5 lines · Andrew Cooper
... to prevent the optimiser creating unsafe code. See the code comment for full details.
Also add a build time check for endbr64 embedded in imm32 operands, which catches the obvious cases where the optimiser has done an unsafe thing.
But this is hardly enough to be safe. I'd even go as far as saying we can do without it if we don't check more thoroughly.
xen/arch/x86/Makefile $(TARGET)-syms: prelink.o xen.lds · line 195
Quoted 9 lines
xen/arch/x86/Makefile +3
-0@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || :
I guess I'm confused: The "false;" suggests to me you want to make the build fail in such a case. The "|| :" otoh suggests you want to silence errors (and not just the one from grep when not finding the pattern aiui).
Also isn't passing -q to grep standard enough (and shorter) to use in place of redirecting its output to /dev/null?
Quoted 33 lines
xen/include/asm-x86/endbr.h new file +30
-0@@ -0,0 +1,55 @@ +/****************************************************************************** +* include/asm-x86/endbr.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +* +* Copyright (c) 2021 Citrix Systems Ltd. +*/ +#ifndef XEN_ASM_ENDBR_H +#define XEN_ASM_ENDBR_H + +#include <xen/compiler.h> + +/* +* In some cases we need to inspect/insert endbr64 instructions. +* +* The naive way, mem{cmp,cpy}(ptr, "\xf3\x0f\x1e\xfa", 4), optimises unsafely +* by placing 0xfa1e0ff3 in an imm32 operand, which marks a legal indirect +* branch target as far as the CPU is concerned. +*
xen/include/asm-x86/endbr.h line 40
Quoted 10 lines
xen/include/asm-x86/endbr.h new file +10
-0+* gen_endbr64() is written deliberately to avoid the problematic operand, and +* marked __const__ as it is safe for the optimiser to hoist/merge/etc. +*/ +static inline uint32_t __attribute_const__ gen_endbr64(void) +{ +uint32_t res; + + asm ("mov $~0xfa1e0ff3, %[res]\n\t" +"not %[res]\n\t" + : [res]"=r" (res) );
Strictly speaking "=&r".
Jan
Re: [PATCH 59.5/65] x86: Introduce helpers/checks for endbr64 instructions
Quoted 8 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper
... to prevent the optimiser creating unsafe code. See the code comment for full details.
Also add a build time check for endbr64 embedded in imm32 operands, which catches the obvious cases where the optimiser has done an unsafe thing.
But this is hardly enough to be safe. I'd even go as far as saying we can do without it if we don't check more thoroughly.
I will do the full check in v2. Marek wrote the full check in response to a discussion about this patch.
Quoted 14 lines
xen/arch/x86/Makefile $(TARGET)-syms: prelink.o xen.lds · line 195
Quoted 10 lines
xen/arch/x86/Makefile +3
-0@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || :I guess I'm confused: The "false;" suggests to me you want to make the build fail in such a case. The "|| :" otoh suggests you want to silence errors (and not just the one from grep when not finding the pattern aiui).
The exit code of grep needs inverting for the build to proceed correctly. Without || :, all builds fail when they've not got the pattern.
Quoted 2 lines
Also isn't passing -q to grep standard enough (and shorter) to use in place of redirecting its output to
/dev/null?
That caused problems on the BSDs. c/s e632d56f0f5 went through several iterations before settling on this pattern.
Quoted 37 lines
Quoted 37 lines
xen/include/asm-x86/endbr.h new file +33
-0@@ -0,0 +1,55 @@ +/****************************************************************************** +* include/asm-x86/endbr.h +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +* +* Copyright (c) 2021 Citrix Systems Ltd. +*/ +#ifndef XEN_ASM_ENDBR_H +#define XEN_ASM_ENDBR_H + +#include <xen/compiler.h> + +/* +* In some cases we need to inspect/insert endbr64 instructions. +* +* The naive way, mem{cmp,cpy}(ptr, "\xf3\x0f\x1e\xfa", 4), optimises unsafely +* by placing 0xfa1e0ff3 in an imm32 operand, which marks a legal indirect +* branch target as far as the CPU is concerned. +* +* gen_endbr64() is written deliberately to avoid the problematic operand, and +* marked __const__ as it is safe for the optimiser to hoist/merge/etc. +*/
Quoted 8 lines
xen/include/asm-x86/endbr.h line 40
Quoted 7 lines
xen/include/asm-x86/endbr.h new file +7
-0+static inline uint32_t __attribute_const__ gen_endbr64(void) +{ +uint32_t res; + + asm ("mov $~0xfa1e0ff3, %[res]\n\t" +"not %[res]\n\t" + : [res]"=r" (res) );Strictly speaking "=&r".
Ok.
~Andrew
Re: [PATCH 59.5/65] x86: Introduce helpers/checks for endbr64 instructions
Quoted 16 lines · Andrew Cooper
Quoted 14 lines · Jan Beulich
xen/arch/x86/Makefile $(TARGET)-syms: prelink.o xen.lds · line 195
Quoted 9 lines · Andrew Cooper
xen/arch/x86/Makefile +3
-0@@ -190,6 +190,10 @@ $(TARGET)-syms: prelink.o xen.lds $(MAKE) -f $(BASEDIR)/Rules.mk efi-y= $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ +ifeq ($(CONFIG_XEN_IBT),y) + $(OBJDUMP) -d $@ | grep 0xfa1e0ff3 >/dev/null && \ + { echo "Found embedded endbr64 instructions" >&2; false; } || :I guess I'm confused: The "false;" suggests to me you want to make the build fail in such a case. The "|| :" otoh suggests you want to silence errors (and not just the one from grep when not finding the pattern aiui).
Quoted 2 lines
The exit code of grep needs inverting for the build to proceed correctly. Without || :, all builds fail when they've not got the pattern.
But doesn't this invert not only failure of grep, but also the unconditional "failure" of "false"? IOW doesn't this step therefore always succeed, making the message merely a warning-like one? Or if that's the intended behavior, what's the "false" good for?
Quoted 5 lines
Quoted 2 lines
Also isn't passing -q to grep standard enough (and shorter) to use in place of redirecting its output to
/dev/null?That caused problems on the BSDs. c/s
e632d56f0f5went through several iterations before settling on this pattern.
Odd. The commit message doesn't mention any of this. v2 of that patch already didn't use -q, and also doesn't identify a respective change from v1. I wasn't able to locate v1.
Jan
PATCH 64/65 x86/efi: Disable CET-IBT around Runtime Services calls
In reply to Andrew CooperAt least one TigerLake NUC has UEFI firmware which isn't CET-IBT compatible. Read under a function pointer to see whether an endbr64 instruction is present, and use this as a heuristic.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
This was disappointing to discover. I've pestered some folk and maybe something will improve in due course, but it remains an open question how best to discover that Runtime Services are CET-IBT compatible.
--- xen/arch/x86/efi/stub.c | 2 ++ xen/common/efi/boot.c | 6 ++++++ xen/common/efi/runtime.c | 17 +++++++++++++++++ xen/include/xen/efi.h | 1 + 4 files changed, 26 insertions(+)
xen/arch/x86/efi/stub.c +2 -0
@@ -11,6 +11,8 @@#include <efi/efidevp.h> #include <efi/efiapi.h> +bool __initdata efi_no_cet_ibt; +/* * Here we are in EFI stub. EFI calls are not supported due to lack * of relevant functionality in compiler and/or linker.
xen/common/efi/boot.c +6 -0
@@ -735,6 +735,12 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdOut = SystemTable->ConOut; StdErr = SystemTable->StdErr ?: StdOut; + +/* +* Heuristic. Look under an arbitrary function pointer to see if UEFI was +* compiled with CET-IBT support. Experimentally some are not. +*/ + efi_no_cet_ibt =memcmp (efi_rs->GetTime,"\xf3\x0f\x1e\xfa" ,4 ) !=0 ; }static void __init efi_console_set_mode (void )
xen/common/efi/runtime.c +17 -0
@@ -21,6 +21,7 @@ struct efi_rs_state {* don't strictly need that. */ unsigned long __aligned(32) cr3; +unsigned long msr_s_cet;#endif };
@@ -61,6 +62,7 @@ UINTN __read_mostly efi_apple_properties_len;/* Bit field representing available EFI features/properties. */ unsigned int efi_flags; +bool __read_mostly efi_no_cet_ibt;struct efi __read_mostly efi = { .acpi =EFI_INVALID_TABLE_ADDR ,
@@ -113,6 +115,17 @@ struct efi_rs_state efi_rs_enter(void)switch_cr3_cr4 (mfn_to_maddr (efi_l4_mfn),read_cr4 ()); +/* +* If UEFI doesn't appear to be CET-IBT compatible, stash and clobber +* ENDBR_EN. Always read the current CET setting, because CET-SS isn't +* configured until very late on the BSP. +*/ +if ( cpu_has_xen_ibt && efi_no_cet_ibt ) + { +rdmsrl (MSR_S_CET , state.msr_s_cet); +wrmsrl (MSR_S_CET , state.msr_s_cet & ~CET_ENDBR_EN ); + } +return state; }
@@ -122,6 +135,10 @@ void efi_rs_leave(struct efi_rs_state *state)if ( !state->cr3 )return ; + +if ( state->msr_s_cet ) +wrmsrl (MSR_S_CET , state->msr_s_cet); +switch_cr3_cr4 (state->cr3,read_cr4 ());if (is_pv_vcpu (curr) && !is_idle_vcpu (curr) ) {
xen/include/xen/efi.h +1 -0
@@ -30,6 +30,7 @@ union compat_pf_efi_info;struct xenpf_efi_runtime_call ;struct compat_pf_efi_runtime_call ; +extern bool efi_no_cet_ibt;bool efi_enabled (unsigned int feature);void efi_init_memory (void );
Signature · 1 line
2.11.0
PATCH 64/65 x86/efi: Disable CET-IBT around Runtime Services calls
In reply to Andrew CooperAt least one TigerLake NUC has UEFI firmware which isn't CET-IBT compatible. Read under a function pointer to see whether an endbr64 instruction is present, and use this as a heuristic.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
This was disappointing to discover. I've pestered some folk and maybe something will improve in due course, but it remains an open question how best to discover that Runtime Services are CET-IBT compatible.
v2:
* Switch to endbr helpers.
--- xen/arch/x86/efi/stub.c | 2 ++ xen/common/efi/boot.c | 9 +++++++++ xen/common/efi/runtime.c | 17 +++++++++++++++++ xen/include/xen/efi.h | 1 + 4 files changed, 29 insertions(+)
xen/arch/x86/efi/stub.c +2 -0
@@ -11,6 +11,8 @@#include <efi/efidevp.h> #include <efi/efiapi.h> +bool __initdata efi_no_cet_ibt; +/* * Here we are in EFI stub. EFI calls are not supported due to lack * of relevant functionality in compiler and/or linker.
xen/common/efi/boot.c +9 -0
@@ -21,6 +21,7 @@#include <xen/string.h> #include <xen/stringify.h> #ifdef CONFIG_X86 +#include <asm/endbr.h> /* * Keep this arch-specific modified include in the common file, as moving * it to the arch specific include file would obscure that special care is
@@ -735,6 +736,14 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdOut = SystemTable->ConOut; StdErr = SystemTable->StdErr ?: StdOut; + +#ifdef CONFIG_X86 +/* +* Heuristic. Look under an arbitrary function pointer to see if UEFI was +* compiled with CET-IBT support. Experimentally some are not. +*/ + efi_no_cet_ibt = !is_endbr64 (efi_rs->GetTime); +#endif }static void __init efi_console_set_mode (void )
xen/common/efi/runtime.c +17 -0
@@ -21,6 +21,7 @@ struct efi_rs_state {* don't strictly need that. */ unsigned long __aligned(32) cr3; +unsigned long msr_s_cet;#endif };
@@ -61,6 +62,7 @@ UINTN __read_mostly efi_apple_properties_len;/* Bit field representing available EFI features/properties. */ unsigned int efi_flags; +bool __read_mostly efi_no_cet_ibt;struct efi __read_mostly efi = { .acpi =EFI_INVALID_TABLE_ADDR ,
@@ -113,6 +115,17 @@ struct efi_rs_state efi_rs_enter(void)switch_cr3_cr4 (mfn_to_maddr (efi_l4_mfn),read_cr4 ()); +/* +* If UEFI doesn't appear to be CET-IBT compatible, stash and clobber +* ENDBR_EN. Always read the current CET setting, because CET-SS isn't +* configured until very late on the BSP. +*/ +if ( cpu_has_xen_ibt && efi_no_cet_ibt ) + { +rdmsrl (MSR_S_CET , state.msr_s_cet); +wrmsrl (MSR_S_CET , state.msr_s_cet & ~CET_ENDBR_EN ); + } +return state; }
@@ -122,6 +135,10 @@ void efi_rs_leave(struct efi_rs_state *state)if ( !state->cr3 )return ; + +if ( state->msr_s_cet ) +wrmsrl (MSR_S_CET , state->msr_s_cet); +switch_cr3_cr4 (state->cr3,read_cr4 ());if (is_pv_vcpu (curr) && !is_idle_vcpu (curr) ) {
xen/include/xen/efi.h +1 -0
@@ -30,6 +30,7 @@ union compat_pf_efi_info;struct xenpf_efi_runtime_call ;struct compat_pf_efi_runtime_call ; +extern bool efi_no_cet_ibt;bool efi_enabled (unsigned int feature);void efi_init_memory (void );
Signature · 1 line
2.11.0
Re: [PATCH v1.1 64/65] x86/efi: Disable CET-IBT around Runtime Services calls
xen/arch/x86/efi/stub.c line 14
Quoted 7 lines · Andrew Cooper
xen/arch/x86/efi/stub.c +1
-0@@ -11,6 +11,8 @@#include <efi/efidevp.h> #include <efi/efiapi.h> +bool __initdata efi_no_cet_ibt;
I'm having trouble seeing what this is needed for - when this file gets built, neither boot.c nor runtime.c will get compiled, and hence there should not be any reference to the symbol that needs satisfying.
xen/arch/x86/efi/stub.c static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl · line 740
Quoted 6 lines
xen/arch/x86/efi/stub.c +2
-0@@ -735,6 +736,14 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdOut = SystemTable->ConOut; StdErr = SystemTable->StdErr ?: StdOut; + +#ifdef CONFIG_X86
CONFIG_XEN_IBT?
xen/arch/x86/efi/stub.c static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl · line 745
Quoted 5 lines
xen/arch/x86/efi/stub.c +5
-0+/* +* Heuristic. Look under an arbitrary function pointer to see if UEFI was +* compiled with CET-IBT support. Experimentally some are not. +*/ + efi_no_cet_ibt = !is_endbr64 (efi_rs->GetTime);
I'm afraid I consider this insufficient. Even if the core EFI was built with IBT support, some driver may not have been. Hence I think there needs to be a command line control to force turning off IBT. The only question is whether we want to also honor its positive form - that would, afaict, be a recipe for a guaranteed crash if used wrongly (and it would be meaningless when used on IBT-aware firmware).
Not only in context of such a command line option I'm also inclined to suggest to invert the polarity of the variable, naming it "efi_cet_ibt" (and the command line sub-option "no-ibt" or "no-cet-ibt").
Jan
Re: [PATCH v1.1 64/65] x86/efi: Disable CET-IBT around Runtime Services calls
Quoted 20 lines · Jan Beulich
xen/arch/x86/efi/stub.c line 14
Quoted 7 lines · Andrew Cooper
xen/arch/x86/efi/stub.c +1
-0@@ -11,6 +11,8 @@#include <efi/efidevp.h> #include <efi/efiapi.h> +bool __initdata efi_no_cet_ibt;I'm having trouble seeing what this is needed for - when this file gets built, neither
boot.cnorruntime.cwill get compiled, and hence there should not be any reference to the symbol that needs satisfying.xen/arch/x86/efi/stub.c static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl · line 740
Quoted 6 lines
xen/arch/x86/efi/stub.c +2
-0@@ -735,6 +736,14 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdOut = SystemTable->ConOut; StdErr = SystemTable->StdErr ?: StdOut; + +#ifdef CONFIG_X86
CONFIG_XEN_IBT?
Quoted 7 lines
xen/arch/x86/efi/stub.c static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl · line 745
Quoted 5 lines
xen/arch/x86/efi/stub.c +5
-0+/* +* Heuristic. Look under an arbitrary function pointer to see if UEFI was +* compiled with CET-IBT support. Experimentally some are not. +*/ + efi_no_cet_ibt = !is_endbr64 (efi_rs->GetTime);I'm afraid I consider this insufficient. Even if the core EFI was built with IBT support, some driver may not have been.
That's not an issue. Everything is built together in practice.
Quoted 5 lines
Hence I think there
needs to be a command line control to force turning off IBT. The only question is whether we want to also honor its positive form - that would, afaict, be a recipe for a guaranteed crash if used wrongly (and it would be meaningless when used on IBT-aware firmware).
It turns out that IBT support is lacking from tianocore, so nothing is going to support IBT for a good while yet.
https://bugzilla.tianocore.org/show_bug.cgi?id=3726 is the proposed change to the spec to support this.
In the meantime, I'm just going to blanket disable IBT for RS calls.
~Andrew
Re: [PATCH v1.1 64/65] x86/efi: Disable CET-IBT around Runtime Services calls
Quoted 26 lines · Andrew Cooper
Quoted 25 lines · Jan Beulich
xen/arch/x86/efi/stub.c line 14
Quoted 7 lines · Andrew Cooper
xen/arch/x86/efi/stub.c +1
-0@@ -11,6 +11,8 @@#include <efi/efidevp.h> #include <efi/efiapi.h> +bool __initdata efi_no_cet_ibt;I'm having trouble seeing what this is needed for - when this file gets built, neither
boot.cnorruntime.cwill get compiled, and hence there should not be any reference to the symbol that needs satisfying.xen/arch/x86/efi/stub.c static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl · line 740
Quoted 6 lines
xen/arch/x86/efi/stub.c +2
-0@@ -735,6 +736,14 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdOut = SystemTable->ConOut; StdErr = SystemTable->StdErr ?: StdOut; + +#ifdef CONFIG_X86
CONFIG_XEN_IBT?Quoted 5 lines
xen/arch/x86/efi/stub.c +5
-0+/* +* Heuristic. Look under an arbitrary function pointer to see if UEFI was +* compiled with CET-IBT support. Experimentally some are not. +*/ + efi_no_cet_ibt = !is_endbr64 (efi_rs->GetTime);
Quoted 4 lines
Quoted 2 lines
I'm afraid I consider this insufficient. Even if the core EFI was built with IBT support, some driver may not have been.
That's not an issue. Everything is built together in practice.
I'd be willing to take your word on this for everything that comes right with the firmware. I'd further be willing to accept that there are no add-in card BIOSes which may get involved. But I highly doubt that what you say applies to all software which may get loaded ahead of starting Xen. Such software may very well register hooks with core EFI.
Quoted 6 lines
Quoted 5 lines
Hence I think there
needs to be a command line control to force turning off IBT. The only question is whether we want to also honor its positive form - that would, afaict, be a recipe for a guaranteed crash if used wrongly (and it would be meaningless when used on IBT-aware firmware).
Quoted 7 lines
It turns out that IBT support is lacking from tianocore, so nothing is going to support IBT for a good while yet.
https://bugzilla.tianocore.org/show_bug.cgi?id=3726 is the proposed change to the spec to support this.
In the meantime, I'm just going to blanket disable IBT for RS calls.
Yeah, that's going to be okay for the time being.
Jan
PATCH 65/65 x86: Enable CET Indirect Branch Tracking
In reply to Andrew CooperWith all the pieces now in place, turn CET-IBT on when available.
MSR_S_CET, like SMEP/SMAP, controls Ring1 meaning that ENDBR_EN can't be enabled for Xen independently of PV32 kernels. As we already disable PV32 for CET-SS, extend this to all CET, adjusting the documentation/comments as appropriate.
Introduce a cet=no-ibt command line option to allow the admin to disable IBT even when everything else is configured correctly.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- docs/misc/xen-command-line.pandoc | 16 +++++++++++---- xen/arch/x86/cpu/common.c | 1 + xen/arch/x86/setup.c | 42 ++++++++++++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 9 deletions(-)
docs/misc/xen-command-line.pandoc +12 -4
@@ -271,7 +271,7 @@ enough. Setting this to a high value may cause boot failure, particularly if the NMI watchdog is also enabled. ### cet - = List of [ shstk=<bool> ] + = List of [ shstk=<bool>, ibt=<bool> ] Applicability: x86
@@ -279,6 +279,10 @@ Controls for the use of Control-flow Enforcement Technology. CET is group a of hardware features designed to combat Return-oriented Programming (ROP, also call/jmp COP/JOP) attacks. +CET is incompatible with 32bit PV guests. If any CET sub-options are active, +they will override the `pv=32` boolean to `false`. Backwards compatibility +can be maintained with the `pv-shim` mechanism. + * The `shstk=` boolean controls whether Xen uses Shadow Stacks for its own protection.
@@ -287,9 +291,13 @@ call/jmp COP/JOP) attacks. `cet=no-shstk` will cause Xen not to use Shadow Stacks even when support is available in hardware. - Shadow Stacks are incompatible with 32bit PV guests. This option will - override the `pv=32` boolean to false. Backwards compatibility can be - maintained with the `pv-shim` mechanism. +* The `ibt=` boolean controls whether Xen uses Indirect Branch Tracking for + its own protection. + + The option is available when `CONFIG_XEN_IBT` is compiled in, and defaults + to `true` on hardware supporting CET-IBT. Specifying `cet=no-ibt` will + cause Xen not to use Indirect Branch Tracking even when support is + available in hardware. ### clocksource (x86) > `= pit | hpet | acpi | tsc`
xen/arch/x86/cpu/common.c +1 -0
@@ -345,6 +345,7 @@ void __init early_cpu_init(void)if (c->cpuid_level >=7 ) {cpuid_count (7 ,0 , &eax, &ebx, &ecx, &edx); c->x86_capability[cpufeat_word (X86_FEATURE_CET_SS )] = ecx; + c->x86_capability[cpufeat_word (X86_FEATURE_CET_IBT )] = edx; } eax =cpuid_eax (0x80000000 );
xen/arch/x86/setup.c +37 -5
70 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 65/65] x86: Enable CET Indirect Branch Tracking
Quoted 11 lines · Andrew Cooper
With all the pieces now in place, turn CET-IBT on when available.
MSR_S_CET, like SMEP/SMAP, controls Ring1 meaning thatENDBR_ENcan't be enabled for Xen independently of PV32 kernels. As we already disable PV32 for CET-SS, extend this to all CET, adjusting the documentation/comments as appropriate.Introduce a cet=no-ibt command line option to allow the admin to disable IBT even when everything else is configured correctly.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 4 lines
xen/arch/x86/setup.c +0
-0@@ -1102,11 +1116,33 @@ void __init noreturn __start_xen(unsigned long mbi_p)printk ("Enabling Supervisor Shadow Stacks\n" );setup_force_cpu_cap (X86_FEATURE_XEN_SHSTK );
xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 1128
Quoted 10 lines
xen/arch/x86/setup.c +10
-0+ } + +if ( opt_xen_ibt &&boot_cpu_has (X86_FEATURE_CET_IBT ) ) + { +printk ("Enabling Indirect Branch Tracking\n" ); + +setup_force_cpu_cap (X86_FEATURE_XEN_IBT ); + +if ( efi_no_cet_ibt ) +printk (" - UEFI Runtime Services not IBT safe\n" );
Here it becomes clear why you need the variable also in efi/stub.c.
Jan
Quoted 97 lines · Andrew Cooper
CET Indirect Branch Tracking is a hardware feature designed to protect against forward-edge control flow hijacking (Call/Jump oriented programming), and is a companion feature to CET Shadow Stacks added in Xen 4.14.
This series depends on lots of previously posted patches. See xenbits/xen-cet-ibt for the full branch with all dependencies.
Patch 1 introduces some compile time infrastructure.
Patches 2 thru 56 annotate all function pointer targets in the common and x86 hypervisor code. Patches are split by API and in no particular order, and largely mechanical. As such, I'm limiting review mainly to The Rest. While doing this work does depend on an experimental GCC change (patch 56), the result does actually work properly with GCC 9 onwards.
Patches 57 thru 65 do the final enablement of CET-IBT.
I have developed this on a TigerLake NUC. Many thanks to Marek who has also given the series a spin on a TigerLake laptop.
Some CI runs, green across the board:
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/416737379
https://cirrus-ci.com/build/6547947216175104Various note accumulated through the work:
* I have already posted patches fixing some of the most egregious (ab)uses of function pointers. There are plenty of other areas which could do with cleanup.
* With everything turned on, we get 1688 runtime endbr64's, and 233 init time. The number of runtime endbr64's is expected to reduce with Juergen's hypercall series (see later), and in common deployment cases where not everything is compiled in by default.
* I have not checked for misaligned endbr64's, and I'm not sure there is anything useful we could do upon discovering that there were any. Naively, there is a 1 in 2^32 chance (endbr64 being 4 bytes long), but this doesn't account for the structure of x86 code, which is most certainly not a uniform random distribution of bytes.
* I have followup work to reduce the number of runtime endbr64's using boot time patching, which further improves the security benefit.
* Patches 2 and 3 are a minimal subset of Juergen's hypercall series, with patch 4 annotating every hypercall. I failed to get the full series pass in CI, so put this together as a stopgap. It reduces the dependencies involved, and patch 4 can be dropped if the hypercall series gets in first.
* The x86 MTRR code is a complete mess, and as far as I can tell, is mostly pre-64bit support. It could do with a prune.
* We do many passes of the MADT counting objects. This is a waste of time and we should count them on a single pass.
* The NUMA setup (SRAT parsing) appears to happen twice. I'm pretty sure this is one too many.Andrew Cooper (63):
x86: Introduce support for CET-IBT
x86/hypercall: Annotate fnptr targets
xen: Annotate fnptr targets fromcustom_param()
xen: Annotate fnptr targets from__initcall()
xen: Annotate fnptr targets from notifier callbacks
xen: Annotate fnptr targets fromacpi_table_parse()
xen: Annotate fnptr targets fromcontinue_hypercall_on_cpu()
xen: Annotate fnptr targets frominit_timer()
xen: Annotate fnptr targets fromcall_rcu()
xen: Annotate fnptr targets from IPIs
xen: Annotate fnptr targets fromopen_softirq()xsm/flask: Annotate fnptr targets in the security server
xsm: Annotate fnptr targets
xen/sched: Annotate fnptr targets
xen/evtchn: Annotate fnptr targets
xen/hypfs: Annotate fnptr targets
xen/tasklet: Annotate fnptr targets xen/keyhandler: Annotate fnptr targets
xen/vpci: Annotate fnptr targets
xen/decompress: Annotate fnptr targets
xen/iommu: Annotate fnptr targets
xen/video: Annotate fnptr targets
xen/console: Annotate fnptr targets
xen/misc: Annotate fnptr targets
x86: Annotate fnptr targets fromrequest_irq()x86/hvm: Annotate fnptr targets fromhvm_funcsx86/hvm: Annotate fnptr targets from device emulation x86/emul: Annotate fnptr targets
x86/ucode: Annotate fnptr targets
x86/power: Annotate fnptr targets
x86/apic: Annotate fnptr targets
x86/nmi: Annotate fnptr targets
x86/mtrr: Annotate fnptr targets
x86/idle: Annotate fnptr targets
x86/quirks: Annotate fnptr targets
x86/hvmsave: Annotate fnptr targets
x86/mce: Annotate fnptr targets
x86/pmu: Annotate fnptr targets
x86/cpu: Annotate fnptr targets
x86/guest: Annotate fnptr targets
x86/logdirty: Annotate fnptr targets
x86/shadow: Annotate fnptr targets
x86/hap: Annotate fnptr targets
x86/p2m: Annotate fnptr targets
x86/irq: Annotate fnptr targets
Quoted 8 lines
x86/aepi: Annotate fnptr targets
x86/psr: Annotate fnptr targets
x86/dpci: Annotate fnptr targets
x86/pt: Annotate fnptr targets
x86/time: Annotate fnptr targets
x86/misc: Annotate fnptr targets
x86/stack: Annotate fnptr targets
x86/bugframe: Annotate fnptr targets
Patches 4-55 as applicable
preferably with the subjects disambiguated and the minor remarks on individual patches taken care of one way or another. It seems to me as if the annotations on declarations are going to obtain a meaning, so I guess I'm okay seeing them added despite not having any function there just yet.
One question though: With the large number of __init functions gaining cf_check, wouldn't it be possible to turn on CET-IBT only when we're done using .init.text?
Jan
Quoted 106 lines · Jan Beulich
Quoted 97 lines · Andrew Cooper
CET Indirect Branch Tracking is a hardware feature designed to protect against forward-edge control flow hijacking (Call/Jump oriented programming), and is a companion feature to CET Shadow Stacks added in Xen 4.14.
This series depends on lots of previously posted patches. See xenbits/xen-cet-ibt for the full branch with all dependencies.
Patch 1 introduces some compile time infrastructure.
Patches 2 thru 56 annotate all function pointer targets in the common and x86 hypervisor code. Patches are split by API and in no particular order, and largely mechanical. As such, I'm limiting review mainly to The Rest. While doing this work does depend on an experimental GCC change (patch 56), the result does actually work properly with GCC 9 onwards.
Patches 57 thru 65 do the final enablement of CET-IBT.
I have developed this on a TigerLake NUC. Many thanks to Marek who has also given the series a spin on a TigerLake laptop.
Some CI runs, green across the board:
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/416737379
https://cirrus-ci.com/build/6547947216175104Various note accumulated through the work:
* I have already posted patches fixing some of the most egregious (ab)uses of function pointers. There are plenty of other areas which could do with cleanup.
* With everything turned on, we get 1688 runtime endbr64's, and 233 init time. The number of runtime endbr64's is expected to reduce with Juergen's hypercall series (see later), and in common deployment cases where not everything is compiled in by default.
* I have not checked for misaligned endbr64's, and I'm not sure there is anything useful we could do upon discovering that there were any. Naively, there is a 1 in 2^32 chance (endbr64 being 4 bytes long), but this doesn't account for the structure of x86 code, which is most certainly not a uniform random distribution of bytes.
* I have followup work to reduce the number of runtime endbr64's using boot time patching, which further improves the security benefit.
* Patches 2 and 3 are a minimal subset of Juergen's hypercall series, with patch 4 annotating every hypercall. I failed to get the full series pass in CI, so put this together as a stopgap. It reduces the dependencies involved, and patch 4 can be dropped if the hypercall series gets in first.
* The x86 MTRR code is a complete mess, and as far as I can tell, is mostly pre-64bit support. It could do with a prune.
* We do many passes of the MADT counting objects. This is a waste of time and we should count them on a single pass.
* The NUMA setup (SRAT parsing) appears to happen twice. I'm pretty sure this is one too many.Andrew Cooper (63):
x86: Introduce support for CET-IBT
x86/hypercall: Annotate fnptr targets
xen: Annotate fnptr targets fromcustom_param()
xen: Annotate fnptr targets from__initcall()
xen: Annotate fnptr targets from notifier callbacks
xen: Annotate fnptr targets fromacpi_table_parse()
xen: Annotate fnptr targets fromcontinue_hypercall_on_cpu()
xen: Annotate fnptr targets frominit_timer()
xen: Annotate fnptr targets fromcall_rcu()
xen: Annotate fnptr targets from IPIs
xen: Annotate fnptr targets fromopen_softirq()xsm/flask: Annotate fnptr targets in the security server
xsm: Annotate fnptr targets
xen/sched: Annotate fnptr targets
xen/evtchn: Annotate fnptr targets
xen/hypfs: Annotate fnptr targets
xen/tasklet: Annotate fnptr targets xen/keyhandler: Annotate fnptr targets
xen/vpci: Annotate fnptr targets
xen/decompress: Annotate fnptr targets
xen/iommu: Annotate fnptr targets
xen/video: Annotate fnptr targets
xen/console: Annotate fnptr targets
xen/misc: Annotate fnptr targets
x86: Annotate fnptr targets fromrequest_irq()x86/hvm: Annotate fnptr targets fromhvm_funcsx86/hvm: Annotate fnptr targets from device emulation x86/emul: Annotate fnptr targets
x86/ucode: Annotate fnptr targets
x86/power: Annotate fnptr targets
x86/apic: Annotate fnptr targets
x86/nmi: Annotate fnptr targets
x86/mtrr: Annotate fnptr targets
x86/idle: Annotate fnptr targets
x86/quirks: Annotate fnptr targets
x86/hvmsave: Annotate fnptr targets
x86/mce: Annotate fnptr targets
x86/pmu: Annotate fnptr targets
x86/cpu: Annotate fnptr targets
x86/guest: Annotate fnptr targets
x86/logdirty: Annotate fnptr targets
x86/shadow: Annotate fnptr targets
x86/hap: Annotate fnptr targets
x86/p2m: Annotate fnptr targets
x86/irq: Annotate fnptr targetsQuoted 8 lines
x86/aepi: Annotate fnptr targets
x86/psr: Annotate fnptr targets
x86/dpci: Annotate fnptr targets
x86/pt: Annotate fnptr targets
x86/time: Annotate fnptr targets
x86/misc: Annotate fnptr targets
x86/stack: Annotate fnptr targets
x86/bugframe: Annotate fnptr targets
Quoted 2 lines
Patches 4-55 as applicable
Acked-by Jan Beulich <[email protected]>
Thanks.
Quoted 9 lines
preferably with the subjects disambiguated and the minor remarks on individual patches taken care of one way or another. It seems to me as if the annotations on declarations are going to obtain a meaning, so I guess I'm okay seeing them added despite not having any function there just yet.
One question though: With the large number of
__initfunctions gainingcf_check, wouldn't it be possible to turn on CET-IBT only when we're done using .init.text?
233 to be precise.
GCC can't distinguish init from non-init functions as far as the improved typechecking (patch 56) goes, so omitting __init would cause compilation issues.
Furthermore, CET-IBT is only one Control Flow Integrity scheme attempting to use a nominally arch-neutral interface. There are others (PaX RAP, and Intel's FineIBT) which have software components to them, and for those, the function pointer callers and callees need to have all appropriate ABI modifications.
I'm pretty certain that if we skipped annotation of the __init functions for now, we'd have to add them in due course anyway.
We could defer enabling CET-IBT until late on boot, but enabling it early gets us better coverage of issues until the first software scheme turns up.
~Andrew
Quoted 10 lines · Andrew Cooper
Quoted 3 lines · Jan Beulich
One question though: With the large number of
__initfunctions gainingcf_check, wouldn't it be possible to turn on CET-IBT only when we're done using .init.text?233 to be precise.
GCC can't distinguish init from non-init functions as far as the improved typechecking (patch 56) goes, so omitting
__initwould cause compilation issues.
Oh, right. Should have been obvious to me, but wasn't.
Jan
Quoted 15 lines
Furthermore, CET-IBT is only one Control Flow Integrity scheme attempting to use a nominally arch-neutral interface. There are others (PaX RAP, and Intel's FineIBT) which have software components to them, and for those, the function pointer callers and callees need to have all appropriate ABI modifications.
I'm pretty certain that if we skipped annotation of the
__initfunctions for now, we'd have to add them in due course anyway.We could defer enabling CET-IBT until late on boot, but enabling it early gets us better coverage of issues until the first software scheme turns up.
~Andrew
Dario Faggioli
Acked-byQuoted 57 lines · Jan Beulich
Quoted 47 lines · Andrew Cooper
Andrew Cooper (63):
x86: Introduce support for CET-IBT
x86/hypercall: Annotate fnptr targets
xen: Annotate fnptr targets fromcustom_param()
xen: Annotate fnptr targets from__initcall()
xen: Annotate fnptr targets from notifier callbacks
xen: Annotate fnptr targets fromacpi_table_parse()
xen: Annotate fnptr targets fromcontinue_hypercall_on_cpu()
xen: Annotate fnptr targets frominit_timer()
xen: Annotate fnptr targets fromcall_rcu()
xen: Annotate fnptr targets from IPIs
xen: Annotate fnptr targets fromopen_softirq()xsm/flask: Annotate fnptr targets in the security server
xsm: Annotate fnptr targets
xen/sched: Annotate fnptr targets
xen/evtchn: Annotate fnptr targets
xen/hypfs: Annotate fnptr targets
xen/tasklet: Annotate fnptr targets xen/keyhandler: Annotate fnptr targets
xen/vpci: Annotate fnptr targets
xen/decompress: Annotate fnptr targets
xen/iommu: Annotate fnptr targets
xen/video: Annotate fnptr targets
xen/console: Annotate fnptr targets
xen/misc: Annotate fnptr targets
x86: Annotate fnptr targets fromrequest_irq()x86/hvm: Annotate fnptr targets fromhvm_funcsx86/hvm: Annotate fnptr targets from device emulation x86/emul: Annotate fnptr targets
x86/ucode: Annotate fnptr targets
x86/power: Annotate fnptr targets
x86/apic: Annotate fnptr targets
x86/nmi: Annotate fnptr targets
x86/mtrr: Annotate fnptr targets
x86/idle: Annotate fnptr targets
x86/quirks: Annotate fnptr targets
x86/hvmsave: Annotate fnptr targets
x86/mce: Annotate fnptr targets
x86/pmu: Annotate fnptr targets
x86/cpu: Annotate fnptr targets
x86/guest: Annotate fnptr targets
x86/logdirty: Annotate fnptr targets
x86/shadow: Annotate fnptr targets
x86/hap: Annotate fnptr targets
x86/p2m: Annotate fnptr targets
x86/irq: Annotate fnptr targetsQuoted 8 lines
x86/aepi: Annotate fnptr targets
x86/psr: Annotate fnptr targets
x86/dpci: Annotate fnptr targets
x86/pt: Annotate fnptr targets
x86/time: Annotate fnptr targets
x86/misc: Annotate fnptr targets
x86/stack: Annotate fnptr targets
x86/bugframe: Annotate fnptr targets
Quoted 3 lines
Patches 4-55 as applicable
Acked-by Jan Beulich <[email protected]>
Patch 16, xen/sched: Annotate fnptr targets:
Quoted 3 lines
preferably with the subjects disambiguated and the minor remarks on individual patches taken care of one way or another.
Yes, FWIW, I agree with Jan here that even just a quick hint at the purpose of the annotation is desirable.
Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)