lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120719235828.GA7121@amt.cnet>
Date:	Thu, 19 Jul 2012 20:58:28 -0300
From:	Marcelo Tosatti <mtosatti@...hat.com>
To:	Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
Cc:	Avi Kivity <avi@...hat.com>, LKML <linux-kernel@...r.kernel.org>,
	KVM <kvm@...r.kernel.org>
Subject: Re: [PATCH 2/9] KVM: x86: simplify read_emulated

On Tue, Jul 17, 2012 at 09:51:34PM +0800, Xiao Guangrong wrote:
> No need split mmio read region into 8-bits pieces since we do it in
> emulator_read_write_onepage
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
> ---
>  arch/x86/kvm/emulate.c |   29 ++++++++++++-----------------
>  1 files changed, 12 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 97d9a99..2d1916b 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -1166,24 +1166,19 @@ static int read_emulated(struct x86_emulate_ctxt *ctxt,
>  	int rc;
>  	struct read_cache *mc = &ctxt->mem_read;
> 
> -	while (size) {
> -		int n = min(size, 8u);
> -		size -= n;
> -		if (mc->pos < mc->end)
> -			goto read_cached;
> -
> -		rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, n,
> -					      &ctxt->exception);
> -		if (rc != X86EMUL_CONTINUE)
> -			return rc;
> -		mc->end += n;
> +	if (mc->pos < mc->end)
> +		goto read_cached;
> 
> -	read_cached:
> -		memcpy(dest, mc->data + mc->pos, n);
> -		mc->pos += n;
> -		dest += n;
> -		addr += n;
> -	}
> +	rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, size,
> +				      &ctxt->exception);
> +	if (rc != X86EMUL_CONTINUE)
> +		return rc;
> +
> +	mc->end += size;
> +
> +read_cached:
> +	memcpy(dest, mc->data + mc->pos, size);

What prevents read_emulated(size > 8) call, with
mc->pos == (mc->end - 8) now?

> +	mc->pos += size;
>  	return X86EMUL_CONTINUE;
>  }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ