Message ID | 1606732298-22107-21-git-send-email-olekstysh@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [V3,01/23] x86/ioreq: Prepare IOREQ feature for making it common | expand |
On 30.11.2020 11:31, Oleksandr Tyshchenko wrote: > --- a/xen/include/xen/sched.h > +++ b/xen/include/xen/sched.h > @@ -552,6 +552,8 @@ struct domain > struct ioreq_server *server[MAX_NR_IOREQ_SERVERS]; > unsigned int nr_servers; > } ioreq_server; > + > + bool mapcache_invalidate; > #endif > }; While I can see reasons to put this inside the #ifdef here, I would suspect putting it in the hole next to the group of 5 bools further up would be more efficient. Jan
On 08.12.20 17:24, Jan Beulich wrote: Hi Jan > On 30.11.2020 11:31, Oleksandr Tyshchenko wrote: >> --- a/xen/include/xen/sched.h >> +++ b/xen/include/xen/sched.h >> @@ -552,6 +552,8 @@ struct domain >> struct ioreq_server *server[MAX_NR_IOREQ_SERVERS]; >> unsigned int nr_servers; >> } ioreq_server; >> + >> + bool mapcache_invalidate; >> #endif >> }; > While I can see reasons to put this inside the #ifdef here, I > would suspect putting it in the hole next to the group of 5 > bools further up would be more efficient. ok, will put (although it will increase the number of #ifdef)
On 08.12.2020 17:49, Oleksandr wrote: > On 08.12.20 17:24, Jan Beulich wrote: >> On 30.11.2020 11:31, Oleksandr Tyshchenko wrote: >>> --- a/xen/include/xen/sched.h >>> +++ b/xen/include/xen/sched.h >>> @@ -552,6 +552,8 @@ struct domain >>> struct ioreq_server *server[MAX_NR_IOREQ_SERVERS]; >>> unsigned int nr_servers; >>> } ioreq_server; >>> + >>> + bool mapcache_invalidate; >>> #endif >>> }; >> While I can see reasons to put this inside the #ifdef here, I >> would suspect putting it in the hole next to the group of 5 >> bools further up would be more efficient. > > ok, will put (although it will increase the number of #ifdef) I was implying no #ifdef in this case, suitably justified by half a sentence in the patch description. Jan
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index ac573c8..6d41c56 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -20,6 +20,7 @@ */ #include <xen/lib.h> #include <xen/hypercall.h> +#include <xen/ioreq.h> #include <xen/nospec.h> #include <asm/hvm/emulate.h> @@ -47,7 +48,7 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) rc = compat_memory_op(cmd, arg); if ( (cmd & MEMOP_CMD_MASK) == XENMEM_decrease_reservation ) - curr->domain->arch.hvm.qemu_mapcache_invalidate = true; + curr->domain->mapcache_invalidate = true; return rc; } @@ -326,9 +327,9 @@ int hvm_hypercall(struct cpu_user_regs *regs) HVM_DBG_LOG(DBG_LEVEL_HCALL, "hcall%lu -> %lx", eax, regs->rax); - if ( unlikely(currd->arch.hvm.qemu_mapcache_invalidate) && - test_and_clear_bool(currd->arch.hvm.qemu_mapcache_invalidate) ) - send_invalidate_req(); + if ( unlikely(currd->mapcache_invalidate) && + test_and_clear_bool(currd->mapcache_invalidate) ) + ioreq_signal_mapcache_invalidate(); return curr->hcall_preempted ? HVM_HCALL_preempted : HVM_HCALL_completed; } diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index a0dd8d1..ba77414 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -64,20 +64,6 @@ void send_timeoffset_req(unsigned long timeoff) gprintk(XENLOG_ERR, "Unsuccessful timeoffset update\n"); } -/* Ask ioemu mapcache to invalidate mappings. */ -void send_invalidate_req(void) -{ - ioreq_t p = { - .type = IOREQ_TYPE_INVALIDATE, - .size = 4, - .dir = IOREQ_WRITE, - .data = ~0UL, /* flush all */ - }; - - if ( ioreq_broadcast(&p, false) != 0 ) - gprintk(XENLOG_ERR, "Unsuccessful map-cache invalidate\n"); -} - bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate, const char *descr) { struct hvm_emulate_ctxt ctxt; diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c index f35dcf9..61ba761 100644 --- a/xen/common/ioreq.c +++ b/xen/common/ioreq.c @@ -35,6 +35,20 @@ #include <public/hvm/ioreq.h> #include <public/hvm/params.h> +/* Ask ioemu mapcache to invalidate mappings. */ +void ioreq_signal_mapcache_invalidate(void) +{ + ioreq_t p = { + .type = IOREQ_TYPE_INVALIDATE, + .size = 4, + .dir = IOREQ_WRITE, + .data = ~0UL, /* flush all */ + }; + + if ( ioreq_broadcast(&p, false) != 0 ) + gprintk(XENLOG_ERR, "Unsuccessful map-cache invalidate\n"); +} + static void set_ioreq_server(struct domain *d, unsigned int id, struct ioreq_server *s) { diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index b8be1ad..cf959f6 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -122,7 +122,6 @@ struct hvm_domain { struct viridian_domain *viridian; - bool_t qemu_mapcache_invalidate; bool_t is_s3_suspended; /* diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h index fb64294..3da0136 100644 --- a/xen/include/asm-x86/hvm/io.h +++ b/xen/include/asm-x86/hvm/io.h @@ -97,7 +97,6 @@ bool relocate_portio_handler( unsigned int size); void send_timeoffset_req(unsigned long timeoff); -void send_invalidate_req(void); bool handle_mmio_with_translation(unsigned long gla, unsigned long gpfn, struct npfec); bool handle_pio(uint16_t port, unsigned int size, int dir); diff --git a/xen/include/xen/ioreq.h b/xen/include/xen/ioreq.h index 2289e79..482f76f 100644 --- a/xen/include/xen/ioreq.h +++ b/xen/include/xen/ioreq.h @@ -129,6 +129,7 @@ struct ioreq_server *ioreq_server_select(struct domain *d, int ioreq_send(struct ioreq_server *s, ioreq_t *proto_p, bool buffered); unsigned int ioreq_broadcast(ioreq_t *p, bool buffered); +void ioreq_signal_mapcache_invalidate(void); void ioreq_domain_init(struct domain *d); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2277995..60bf254 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -552,6 +552,8 @@ struct domain struct ioreq_server *server[MAX_NR_IOREQ_SERVERS]; unsigned int nr_servers; } ioreq_server; + + bool mapcache_invalidate; #endif };