From: Laszlo Ersek <lersek@redhat.com>
To: Kevin O'Connor <kevin@koconnor.net>
Cc: matt.fleming@intel.com, mdroth@linux.vnet.ibm.com,
rjones@redhat.com, jordan.l.justen@intel.com,
"Gabriel L. Somlo" <somlo@cmu.edu>,
gleb@cloudius-systems.com, qemu-devel@nongnu.org,
gsomlo@gmail.com, kraxel@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 6/6] qga: RFC: guest-side retrieval of fw_cfg file
Date: Thu, 19 Mar 2015 19:44:25 +0100 [thread overview]
Message-ID: <550B1909.7070501@redhat.com> (raw)
In-Reply-To: <20150319182755.GA890@morn.localdomain>
On 03/19/15 19:27, Kevin O'Connor wrote:
> On Tue, Mar 17, 2015 at 01:38:06PM +0100, Laszlo Ersek wrote:
>> On 03/16/15 15:15, Gabriel L. Somlo wrote:
>>> 1. I can't for the life of me figure out how to stop gcc -O2
>>> from assuming the if() test below is ALWAYS FALSE, and thus
>>> optimizing it out completely. For now I've forced -O0 on
>>> the entire function, but for some reason fw_cfg_read(&fcfile, ...)
>>> does not appear to count as potentially modifying fcfile...
> [...]
>>> +static void
>>> +fw_cfg_read(void *buf, int len)
>>> +{
>>> + insb(PORT_FW_CFG_DATA, buf, len);
>>> +}
> [...]
>> I think fw_cfg_read() is inlined under -O2, and the insb() from that
>> function is somehow confusing gcc.
>>
>> From "/usr/include/sys/io.h", on my RHEL-7.1 laptop:
>>
>> static __inline void
>> insb (unsigned short int __port, void *__addr, unsigned long int __count)
>> {
>> __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
>> :"d" (__port), "0" (__addr), "1" (__count));
>> }
>
> My read of this is that gcc knows it must emit the instruction, and it
> knows that __addr and __count can change. But, it doesn't know that
> the memory at *__addr can change. I'd see if a barrier() fixes it.
>
> See the section on "clobber" at:
>
> https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
>
> In particular:
>
> You can use a trick to avoid this if the size of the memory being
> accessed is known at compile time. For example, if accessing ten bytes
> of a string, use a memory input like:
>
> {"m"( ({ struct { char x[10]; } *p = (void *)ptr ; *p; }) )}.
I think you nailed it, thanks.
Laszlo
next prev parent reply other threads:[~2015-03-19 18:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 14:14 [Qemu-devel] [PATCH 0/6] fw-cfg: documentation, cleanup, and proposed feature Gabriel L. Somlo
2015-03-16 14:15 ` [Qemu-devel] [PATCH 1/6] fw_cfg: add documentation file (docs/specs/fw_cfg.txt) Gabriel L. Somlo
2015-03-16 16:30 ` Laszlo Ersek
2015-03-16 14:15 ` [Qemu-devel] [PATCH 2/6] fw_cfg: remove support for guest-side data writes Gabriel L. Somlo
2015-03-16 17:02 ` Laszlo Ersek
2015-03-16 18:41 ` Gabriel L. Somlo
2015-03-17 7:46 ` Gerd Hoffmann
2015-03-16 14:15 ` [Qemu-devel] [PATCH 3/6] fw_cfg: assertion to detect memory leak when adding new data blob Gabriel L. Somlo
2015-03-16 19:12 ` Laszlo Ersek
2015-03-16 14:15 ` [Qemu-devel] [PATCH 4/6] fw_cfg: exit with error when dupe fw_cfg file name inserted Gabriel L. Somlo
2015-03-16 19:26 ` Laszlo Ersek
2015-03-16 14:15 ` [Qemu-devel] [PATCH 5/6] fw_cfg: insert fw_cfg file blobs via qemu cmdline Gabriel L. Somlo
2015-03-17 10:07 ` Gerd Hoffmann
2015-03-17 10:55 ` Matt Fleming
2015-03-17 14:09 ` Gabriel L. Somlo
2015-03-17 11:28 ` Laszlo Ersek
2015-03-17 11:49 ` Gerd Hoffmann
2015-03-18 20:06 ` Gabriel L. Somlo
2015-03-19 10:43 ` Laszlo Ersek
2015-03-18 20:27 ` Gabriel L. Somlo
2015-03-19 7:34 ` Gerd Hoffmann
2015-03-19 8:41 ` [Qemu-devel] How to emit errors with nice location information (was: [PATCH 5/6] fw_cfg: insert fw_cfg file blobs via qemu cmdline) Markus Armbruster
2015-03-16 14:15 ` [Qemu-devel] [PATCH 6/6] qga: RFC: guest-side retrieval of fw_cfg file Gabriel L. Somlo
2015-03-17 12:38 ` Laszlo Ersek
2015-03-17 14:28 ` Gabriel L. Somlo
2015-03-19 18:27 ` Kevin O'Connor
2015-03-19 18:44 ` Laszlo Ersek [this message]
2015-03-16 14:26 ` [Qemu-devel] [PATCH 0/6] fw-cfg: documentation, cleanup, and proposed feature Patchew Tool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550B1909.7070501@redhat.com \
--to=lersek@redhat.com \
--cc=gleb@cloudius-systems.com \
--cc=gsomlo@gmail.com \
--cc=jordan.l.justen@intel.com \
--cc=kevin@koconnor.net \
--cc=kraxel@redhat.com \
--cc=matt.fleming@intel.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--cc=somlo@cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).