From: "Jan Beulich" Subject: Re: [PATCH v7 07/15] x86/hvm: unify stdvga mmio intercept with standard mmio intercept Date: Thu, 09 Jul 2015 16:33:11 +0100 Message-ID: <559EB057020000780008EEE8@mail.emea.novell.com> References: <1436447455-11524-1-git-send-email-paul.durrant@citrix.com> <1436447455-11524-8-git-send-email-paul.durrant@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1436447455-11524-8-git-send-email-paul.durrant@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Paul Durrant Cc: Keir Fraser , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 09.07.15 at 15:10, wrote: > @@ -424,8 +426,22 @@ static void stdvga_mem_writeb(uint64_t addr, uint32_t val) > } > } > > -static void stdvga_mem_write(uint64_t addr, uint64_t data, uint64_t size) > +static int stdvga_mem_write(const struct hvm_io_handler *handler, > + uint64_t addr, uint32_t size, > + uint64_t data) > { > + struct hvm_hw_stdvga *s = ¤t->domain->arch.hvm_domain.stdvga; > + ioreq_t p = { .type = IOREQ_TYPE_COPY, > + .addr = addr, > + .size = size, > + .count = 1, > + .dir = IOREQ_WRITE, > + .data = data, > + }; Indentation (still - I know I pointed this out on v6, just perhaps at another example). See e.g. the context of the earlier change to the beginning of hvm_mmio_internal() in this patch for how this should look like. > -int stdvga_intercept_mmio(ioreq_t *p) > +static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler, > + const ioreq_t *p) > { > - struct domain *d = current->domain; > - struct hvm_hw_stdvga *s = &d->arch.hvm_domain.stdvga; > - uint64_t start, end, addr = p->addr, count = p->count, size = p->size; > - int buf = 0, rc; > - > - if ( unlikely(p->df) ) > - { > - start = (addr - (count - 1) * size); > - end = addr + size; > - } > - else > - { > - start = addr; > - end = addr + count * size; > - } > - > - if ( (start < VGA_MEM_BASE) || (end > (VGA_MEM_BASE + VGA_MEM_SIZE)) ) > - return X86EMUL_UNHANDLEABLE; > - > - if ( size > 8 ) > - { > - gdprintk(XENLOG_WARNING, "invalid mmio size %d\n", (int)p->size); > - return X86EMUL_UNHANDLEABLE; > - } > + struct hvm_hw_stdvga *s = ¤t->domain->arch.hvm_domain.stdvga; > > spin_lock(&s->lock); > > - if ( s->stdvga && s->cache ) > + if ( !s->stdvga || > + (hvm_mmio_first_byte(p) < VGA_MEM_BASE) || > + (hvm_mmio_last_byte(p) > (VGA_MEM_BASE + VGA_MEM_SIZE)) ) If "last" means what is says, you need >= here. Jan