From: Wei Liu <wei.liu2@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
xen-devel@lists.xen.org, Jan Beulich <JBeulich@suse.com>,
Keir Fraser <keir@xen.org>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v3 11/16] hvmloader: Load OVMF from modules
Date: Sat, 5 Mar 2016 18:05:36 +0000 [thread overview]
Message-ID: <20160305180536.GC14571@citrix.com> (raw)
In-Reply-To: <20160303173950.GP7532@perard.uk.xensource.com>
On Thu, Mar 03, 2016 at 05:39:50PM +0000, Anthony PERARD wrote:
> On Tue, Mar 01, 2016 at 09:03:42AM -0700, Jan Beulich wrote:
> > >>> On 25.02.16 at 15:56, <anthony.perard@citrix.com> wrote:
> > > --- a/tools/firmware/hvmloader/ovmf.c
> > > +++ b/tools/firmware/hvmloader/ovmf.c
> > > @@ -34,17 +34,10 @@
> > > #include <xen/hvm/ioreq.h>
> > > #include <xen/memory.h>
> > >
> > > -#define ROM_INCLUDE_OVMF
> > > -#include "roms.inc"
> > > -
> > > -#define OVMF_SIZE (sizeof(ovmf))
> > > #define OVMF_MAXOFFSET 0x000FFFFFULL
> > > -#define OVMF_BEGIN (0x100000000ULL - ((OVMF_SIZE + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET))
> > > -#define OVMF_END (OVMF_BEGIN + OVMF_SIZE)
> > > #define LOWCHUNK_BEGIN 0x000F0000
> > > #define LOWCHUNK_SIZE 0x00010000
> > > #define LOWCHUNK_MAXOFFSET 0x0000FFFF
> > > -#define LOWCHUNK_END (OVMF_BEGIN + OVMF_SIZE)
> > > #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
> > >
> > > extern unsigned char dsdt_anycpu_qemu_xen[];
> > > @@ -97,16 +90,20 @@ static void ovmf_load(const struct bios_config *config,
> > > void *bios_addr, uint32_t bios_length)
> > > {
> > > xen_pfn_t mfn;
> > > - uint64_t addr = OVMF_BEGIN;
> > > + uint64_t addr = 0x100000000ULL
> > > + - ((bios_length + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET);
> > > + uint64_t ovmf_end = addr + bios_length;
> > > +
> > > + ovmf_config.bios_address = addr;
> > > + ovmf_config.image_size = bios_length;
> > >
> > > /* Copy low-reset vector portion. */
> > > - memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
> > > - + OVMF_SIZE
> > > - - LOWCHUNK_SIZE,
> > > + memcpy((void *) LOWCHUNK_BEGIN,
> > > + (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,
> > > LOWCHUNK_SIZE);
> > >
> > > /* Ensure we have backing page prior to moving FD. */
> > > - while ( (addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT) )
> > > + while ( (addr >> PAGE_SHIFT) != (ovmf_end >> PAGE_SHIFT) )
> > > {
> > > mfn = (uint32_t) (addr >> PAGE_SHIFT);
> > > addr += PAGE_SIZE;
> > > @@ -114,7 +111,7 @@ static void ovmf_load(const struct bios_config *config,
> > > }
> > >
> > > /* Copy FD. */
> > > - memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
> > > + memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
> > > }
> >
> > Is this safe, considering that source and destination may now
> > overlap? Thinking about it, the same consideration applies to
> > BIOS placement below 1Mb too.
>
> It's probably not safe, it just happen to work right now. I guest I can add
> some checking, or leave it up to libxc to manage the memory and write this
> blob just after hvmloader, like it's done right now.
>
> I think I'll add some bug_on to catch unexpected changes.
>
If the only concern is overlapping region (not overwriting something
that needs to be used later), using memmove should be good enough?
Wei.
> --
> Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-05 18:05 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 14:55 [PATCH v3 00/16] Load BIOS via toolstack instead of been embedded in hvmloader Anthony PERARD
2016-02-25 14:55 ` [PATCH v3 01/16] libxc: Rework extra module initialisation Anthony PERARD
2016-03-01 11:51 ` Wei Liu
2016-03-03 16:27 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 02/16] libxc: Load BIOS and ACPI table into guest memory Anthony PERARD
2016-03-01 11:51 ` Wei Liu
2016-03-03 16:57 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 03/16] configure: #define SEABIOS_PATH and OVMF_PATH Anthony PERARD
2016-03-01 11:51 ` Wei Liu
2016-03-03 17:03 ` Anthony PERARD
2016-03-08 15:55 ` Wei Liu
2016-02-25 14:56 ` [PATCH v3 04/16] firmware/makefile: install BIOS and ACPI blob Anthony PERARD
2016-02-29 16:31 ` Jan Beulich
2016-03-03 15:44 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 05/16] libxl: Load guest BIOS from file Anthony PERARD
2016-03-01 11:51 ` Wei Liu
2016-03-03 17:16 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 06/16] libxl: Load guest ACPI table " Anthony PERARD
2016-03-01 11:51 ` Wei Liu
2016-03-03 17:12 ` Anthony PERARD
2016-03-08 15:55 ` Wei Liu
2016-02-25 14:56 ` [PATCH v3 07/16] hvmloader: Grab the hvm_start_info pointer Anthony PERARD
2016-02-29 16:37 ` Jan Beulich
2016-02-29 16:48 ` Jan Beulich
2016-02-25 14:56 ` [PATCH v3 08/16] hvmloader: Locate the BIOS blob Anthony PERARD
2016-02-29 16:56 ` Jan Beulich
2016-03-03 16:21 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 09/16] hvmloader: Check modules whereabouts Anthony PERARD
2016-02-29 16:58 ` Jan Beulich
2016-03-03 16:00 ` Anthony PERARD
2016-03-03 16:18 ` Jan Beulich
2016-03-03 16:34 ` Andrew Cooper
2016-02-25 14:56 ` [PATCH v3 10/16] hvmloader: Load SeaBIOS from hvm_start_info modules Anthony PERARD
2016-02-29 17:02 ` Jan Beulich
2016-03-03 16:15 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 11/16] hvmloader: Load OVMF from modules Anthony PERARD
2016-03-01 16:03 ` Jan Beulich
2016-03-03 17:39 ` Anthony PERARD
2016-03-05 18:05 ` Wei Liu [this message]
2016-02-25 14:56 ` [PATCH v3 12/16] hvmloader: Specific bios_load function required Anthony PERARD
2016-03-01 16:07 ` Jan Beulich
2016-02-25 14:56 ` [PATCH v3 13/16] hvmloader: Load ACPI tables from hvm_start_info module Anthony PERARD
2016-03-01 16:17 ` Jan Beulich
2016-03-03 17:59 ` Anthony PERARD
2016-03-04 8:39 ` Jan Beulich
2016-03-08 11:15 ` Anthony PERARD
2016-02-25 14:56 ` [PATCH v3 14/16] hvmloader: Compile out the qemu-xen ACPI tables Anthony PERARD
2016-03-01 16:19 ` Jan Beulich
2016-02-25 14:56 ` [PATCH v3 15/16] hvmloader: Always build-in SeaBIOS and OVMF loader Anthony PERARD
2016-03-01 16:20 ` Jan Beulich
2016-02-25 14:56 ` [PATCH v3 16/16] hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH Anthony PERARD
2016-03-01 16:24 ` Jan Beulich
2016-03-03 11:38 ` Wei Liu
2016-02-25 16:16 ` [PATCH v3 00/16] Load BIOS via toolstack instead of been embedded in hvmloader Boris Ostrovsky
2016-02-25 16:43 ` Anthony PERARD
2016-03-03 18:03 ` Anthony PERARD
2016-03-04 10:57 ` Andrew Cooper
2016-03-08 11:21 ` Anthony PERARD
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=20160305180536.GC14571@citrix.com \
--to=wei.liu2@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=keir@xen.org \
--cc=roger.pau@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/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).