[Qemu-devel] [PATCH v2] allwinner-a10: add config script support
sunxi-linux kernel parses a special config script to do hardware configuration, bootloader loads script into fixed RAM address, then kernel will learn from it. this script is transformed from a text script into binary by a tool. reference: http://linux-sunxi.org/Sunxi-tools script file address: http://dl.dbank.com/c00aonvlmw Signed-off-by: liguang --- hw/arm/allwinner-a10.c | 27 +++ hw/arm/cubieboard.c|2 ++ include/hw/arm/allwinner-a10.h |5 + 3 files changed, 34 insertions(+), 0 deletions(-) diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 4658e19..f65b40b 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -18,6 +18,33 @@ #include "hw/sysbus.h" #include "hw/devices.h" #include "hw/arm/allwinner-a10.h" +#include "hw/loader.h" +#include "sysemu/sysemu.h" + +void aw_a10_load_script(void) +{ +char *file_name; +int file_size; + +if (bios_name == NULL) { +bios_name = AW_CONFIG_SCRIPT; +} + +file_name = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); +if (file_name == NULL) { +error_report("can't find %s\n", bios_name); +return; +} +file_size = get_image_size(file_name); +if (file_size < 0) { +error_report("can't get file size of %s\n", file_name); +return; +} +if (load_image_targphys(file_name, AW_SCRIPT_ADDR, file_size) < 0) { +error_report("can't load %s\n", file_name); +return; +} +} static void aw_a10_init(Object *obj) { diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 3fcb6d2..8482974 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -48,6 +48,8 @@ static void cubieboard_init(QEMUMachineInitArgs *args) memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE, &s->sdram); +aw_a10_load_script(); + cubieboard_binfo.ram_size = args->ram_size; cubieboard_binfo.kernel_filename = args->kernel_filename; cubieboard_binfo.kernel_cmdline = args->kernel_cmdline; diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h index da36647..ad20659 100644 --- a/include/hw/arm/allwinner-a10.h +++ b/include/hw/arm/allwinner-a10.h @@ -17,6 +17,9 @@ #define AW_A10_SDRAM_BASE 0x4000 +#define AW_CONFIG_SCRIPT"script.bin" +#define AW_SCRIPT_ADDR 0x4300 + #define TYPE_AW_A10 "allwinner-a10" #define AW_A10(obj) OBJECT_CHECK(AwA10State, (obj), TYPE_AW_A10) @@ -31,5 +34,7 @@ typedef struct AwA10State { AwA10PICState intc; } AwA10State; +void aw_a10_load_script(void); + #define ALLWINNER_H_ #endif -- 1.7.2.5
Re: [Qemu-devel] [PATCHv4] block: add native support for NFS
On Wed, Dec 25, 2013 at 9:42 PM, Fam Zheng wrote: > On 2013年12月21日 00:04, Peter Lieven wrote: >> >> This patch adds native support for accessing images on NFS shares without >> the requirement to actually mount the entire NFS share on the host. >> >> NFS Images can simply be specified by an url of the form: >> nfs: >> >> For example: >> qemu-img create -f qcow2 nfs://10.0.0.1/qemu-images/test.qcow2 >> >> You need LibNFS from Ronnie Sahlberg available at: >> git://github.com/sahlberg/libnfs.git >> for this to work. >> >> During configure it is automatically probed for libnfs and support >> is enabled on-the-fly. You can forbid or enforce libnfs support >> with --disable-libnfs or --enable-libnfs respectively. >> >> Due to NFS restrictions you might need to execute your binaries >> as root, allow them to open priviledged ports (<1024) or specify >> insecure option on the NFS server. >> > > What are the error messages like, if no privilege. Is root always required > for this to work? NFS servers often default to only allow client connections that originates from a system port. I know three different ways to solve this: 1, Run QEMU as root, which allows libnfs to bind to a system port. This is probably suboptimal since I guess most people would want to avoid running qemu as root if they can avoid it. 2, Change the NFS server to allow connections from nonsystem ports. On linux NFS servers this is done by adding "insecure" as the export option in /etc/exports. This may be preferable to option 1 (since secure/insecure does not really add much security in the first place). 3, Assign the capability to qemu to bind to system ports when running as non-root user. This is probably the most attractive option of the three. You can still run qemu as non-root and you dont have to change the security mode on the NFS server. It is highly non-portable though and only work on platforms that provide capabilities. On linux you add this capability using : sudo setcap 'cap_net_bind_service=+ep' /path/to/executable regards ronnie sahlberg
Re: [Qemu-devel] [PATCHv4] block: add native support for NFS
On 2013年12月21日 00:04, Peter Lieven wrote: This patch adds native support for accessing images on NFS shares without the requirement to actually mount the entire NFS share on the host. NFS Images can simply be specified by an url of the form: nfs: For example: qemu-img create -f qcow2 nfs://10.0.0.1/qemu-images/test.qcow2 You need LibNFS from Ronnie Sahlberg available at: git://github.com/sahlberg/libnfs.git for this to work. During configure it is automatically probed for libnfs and support is enabled on-the-fly. You can forbid or enforce libnfs support with --disable-libnfs or --enable-libnfs respectively. Due to NFS restrictions you might need to execute your binaries as root, allow them to open priviledged ports (<1024) or specify insecure option on the NFS server. What are the error messages like, if no privilege. Is root always required for this to work? LibNFS currently support NFS version 3 only. Signed-off-by: Peter Lieven --- v3->v4: - finally added full implementation of bdrv_get_allocated_file_size [Stefan] - removed trailing \n from error statements [Stefan] v2->v3: - rebased the stefanha/block - use pkg_config to check for libnfs (ignoring cflags which are broken in 1.8.0) [Stefan] - fixed NFSClient declaration [Stefan] - renamed Task variables to task [Stefan] - renamed NFSTask to NFSRPC [Ronnie] - do not update bs->total_sectors in nfs_co_writev [Stefan] - return -ENOMEM on all async call failures [Stefan,Ronnie] - fully implement ftruncate - use util/uri.c for URL parsing [Stefan] - reworked nfs_file_open_common to nfs_client_open which works on NFSClient [Stefan] - added a comment ot the connect message that libnfs support NFSv3 only at the moment. - DID NOT add full implementation of bdrv_get_allocated_file_size because we are not in a coroutine context and I cannot do an async call here. I could do a sync call if there would be a guarantee that no requests are in flight. [Stefan] v1->v2: - fixed block/Makefile.objs [Ronnie] - do not always register a read handler [Ronnie] - add support for reading beyond EOF [Fam] - fixed struct and paramter naming [Fam] - fixed overlong lines and whitespace errors [Fam] - return return status from libnfs whereever possible [Fam] - added comment why we set allocated_file_size to -ENOTSUP after write [Fam] - avoid segfault when parsing filname [Fam] - remove unused close_bh from NFSClient [Fam] - avoid dividing and mutliplying total_size by BDRV_SECTOR_SIZE in nfs_file_create [Fam] MAINTAINERS |5 + block/Makefile.objs |1 + block/nfs.c | 414 +++ configure | 26 4 files changed, 446 insertions(+) create mode 100644 block/nfs.c diff --git a/MAINTAINERS b/MAINTAINERS index a5ab8f8..09996ab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -935,6 +935,11 @@ M: Peter Lieven S: Supported F: block/iscsi.c +NFS +M: Peter Lieven +S: Maintained +F: block/nfs.c + SSH M: Richard W.M. Jones S: Supported diff --git a/block/Makefile.objs b/block/Makefile.objs index 4e8c91e..e254a21 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -12,6 +12,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o ifeq ($(CONFIG_POSIX),y) block-obj-y += nbd.o nbd-client.o sheepdog.o block-obj-$(CONFIG_LIBISCSI) += iscsi.o +block-obj-$(CONFIG_LIBNFS) += nfs.o block-obj-$(CONFIG_CURL) += curl.o block-obj-$(CONFIG_RBD) += rbd.o block-obj-$(CONFIG_GLUSTERFS) += gluster.o diff --git a/block/nfs.c b/block/nfs.c new file mode 100644 index 000..78fd8a1 --- /dev/null +++ b/block/nfs.c @@ -0,0 +1,414 @@ +/* + * QEMU Block driver for native access to files on NFS shares + * + * Copyright (c) 2013 Peter Lieven + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "config-host.h" + +#include +#include "qemu-common.h" +#include "qemu/config-fi
[Qemu-devel] [PATCH] acpi unit-test: Remove temporary disk after test
Signed-off-by: Fam Zheng --- tests/acpi-test.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index ca83b1d6..df1af83 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -382,6 +382,7 @@ int main(int argc, char *argv[]) { const char *arch = qtest_get_arch(); FILE *f = fopen(disk, "w"); +int ret; fwrite(boot_sector, 1, sizeof boot_sector, f); fclose(f); @@ -390,5 +391,7 @@ int main(int argc, char *argv[]) if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { qtest_add_func("acpi/tcg", test_acpi_tcg); } -return g_test_run(); +ret = g_test_run(); +unlink(disk); +return ret; } -- 1.8.5.1
Re: [Qemu-devel] [PATCH v2 10/24] block: Introduce bdrv_co_do_preadv()
> /* throttling disk I/O */ > if (bs->io_limits_enabled) { > -bdrv_io_limits_intercept(bs, nb_sectors, false); > +bdrv_io_limits_intercept(bs, bytes >> BDRV_SECTOR_BITS, false); > +} Is it possible (bytes >> BDRV_SECTOR_BITS) == 0? >
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
Peter Maydell wrote: On 26 December 2013 01:09, Peter Crosthwaite wrote: Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)? Well, we do already have that (see -machine firmware=whatever), but... Yes, right. I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU. ...it's much easier to keep the blob outside QEMU because otherwise it has to have a git submodule and be built somehow and is generally a bit of a faff. Is this FEX stuff actually supported by the upstream Linux kernel? Googling mostly produced a bunch of stuff from a mid-year flamewar. I definitely don't think we should add any special support for it in QEMU if it's just some random thing that isn't going to be upstreamed. OK, I will use firmware=script.bin option, thanks!
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
On 26 December 2013 01:09, Peter Crosthwaite wrote: > Can you just provide a generic solution to the "blob some random data > into RAM" problem (If one doesn't exist already)? Well, we do already have that (see -machine firmware=whatever), but... > I think your binary file here can then just be treated as any other > binary boot product and kept outside of QEMU. ...it's much easier to keep the blob outside QEMU because otherwise it has to have a git submodule and be built somehow and is generally a bit of a faff. Is this FEX stuff actually supported by the upstream Linux kernel? Googling mostly produced a bunch of stuff from a mid-year flamewar. I definitely don't think we should add any special support for it in QEMU if it's just some random thing that isn't going to be upstreamed. thanks -- PMM
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
Peter Crosthwaite wrote: On Thu, Dec 26, 2013 at 10:47 AM, Peter Maydell wrote: On 26 December 2013 00:39, Li Guang wrote: Peter Maydell wrote: On 26 December 2013 00:14, Li Guang wrote: it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like: [card0_boot_para] card_ctrl = 0 card_high_speed = 1 card_line = 4 sdc_d1 = port:PF00<2><1> sdc_d0 = port:PF01<2><1> sdc_clk = port:PF02<2><1> sdc_cmd = port:PF03<2><1> sdc_d3 = port:PF04<2><1> sdc_d2 = port:PF05<2><1> So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash? it's generally in /boot, bootloader will load it into ram address 0x4300, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used. Weird. Why isn't this just using devicetree? I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it... Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)? I toyed with the Idea of a bootloader as a device a while back, which would allow you to implement multiple bootloaders unaware of each other, with arbitrary command line args: http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg00858.html That patch demonstrates creating a bootloader as a QOM object. Its ancient, so the style is way out of date, but the idea is still there. So you could use the ARM linux loader as is, then blob your firmware in on the side something like: qemu-system-arm -device blob-loader,addr=0x4300,file=/path/to/blob -kernel ... that's a good option. I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU. Yes, I would like to keep it outside of QEMU, what's about directly add an abstract device called "blob"? and the device has it's properties like path, address...
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
On Thu, Dec 26, 2013 at 10:47 AM, Peter Maydell wrote: > On 26 December 2013 00:39, Li Guang wrote: >> Peter Maydell wrote: >>> >>> On 26 December 2013 00:14, Li Guang wrote: it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like: [card0_boot_para] card_ctrl = 0 card_high_speed = 1 card_line = 4 sdc_d1 = port:PF00<2><1> sdc_d0 = port:PF01<2><1> sdc_clk = port:PF02<2><1> sdc_cmd = port:PF03<2><1> sdc_d3 = port:PF04<2><1> sdc_d2 = port:PF05<2><1> >>> >>> So what sets this up on real hardware? Is this part of >>> a firmware blob? Is it in ROM or flash? > >> it's generally in /boot, bootloader will load it >> into ram address 0x4300, kernel will find it >> at this fixed address, and parse it, learn the hardware >> related configuration, mostly property of devices, and >> GPIOes used. > > Weird. Why isn't this just using devicetree? > I'd rather not have to add support to QEMU's bootloader > for weird things like this if I can avoid it... > Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)? I toyed with the Idea of a bootloader as a device a while back, which would allow you to implement multiple bootloaders unaware of each other, with arbitrary command line args: http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg00858.html That patch demonstrates creating a bootloader as a QOM object. Its ancient, so the style is way out of date, but the idea is still there. So you could use the ARM linux loader as is, then blob your firmware in on the side something like: qemu-system-arm -device blob-loader,addr=0x4300,file=/path/to/blob -kernel ... I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU. Regards, Peter > Who provides this file? The board manufacturer? > Where's the source? How do you create the blob? > What license are the sources under? > > thanks > -- PMM >
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
Peter Maydell wrote: On 26 December 2013 00:39, Li Guang wrote: Peter Maydell wrote: On 26 December 2013 00:14, Li Guang wrote: it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like: [card0_boot_para] card_ctrl = 0 card_high_speed = 1 card_line = 4 sdc_d1 = port:PF00<2><1> sdc_d0 = port:PF01<2><1> sdc_clk = port:PF02<2><1> sdc_cmd = port:PF03<2><1> sdc_d3 = port:PF04<2><1> sdc_d2 = port:PF05<2><1> So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash? it's generally in /boot, bootloader will load it into ram address 0x4300, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used. Weird. Why isn't this just using devicetree? don't know the exactly reason linux-sunxi community do this(actually, the script parsing code mostly wrote by engineer from Allwinner). I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it... Who provides this file? The board manufacturer? Where's the source? How do you create the blob? What license are the sources under? the file will vary for different board, we can created by our-self, just write the formatted text script, and transform it to binary by a tool, refer to: http://linux-sunxi.org/Sunxi-tools Thanks!
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
On 26 December 2013 00:39, Li Guang wrote: > Peter Maydell wrote: >> >> On 26 December 2013 00:14, Li Guang wrote: >>> it's the approach sunxi-linux kernel config hardware, >>> the binary is actually a transformed text script, >>> and context of script is like: >>> >>> [card0_boot_para] >>> card_ctrl = 0 >>> card_high_speed = 1 >>> card_line = 4 >>> sdc_d1 = port:PF00<2><1> >>> sdc_d0 = port:PF01<2><1> >>> sdc_clk = port:PF02<2><1> >>> sdc_cmd = port:PF03<2><1> >>> sdc_d3 = port:PF04<2><1> >>> sdc_d2 = port:PF05<2><1> >>> >> >> So what sets this up on real hardware? Is this part of >> a firmware blob? Is it in ROM or flash? > it's generally in /boot, bootloader will load it > into ram address 0x4300, kernel will find it > at this fixed address, and parse it, learn the hardware > related configuration, mostly property of devices, and > GPIOes used. Weird. Why isn't this just using devicetree? I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it... Who provides this file? The board manufacturer? Where's the source? How do you create the blob? What license are the sources under? thanks -- PMM
Re: [Qemu-devel] [PATCH] hw/sd: move sdhci.h to include/hw
Peter Maydell wrote: On 26 December 2013 00:22, Li Guang wrote: Peter Maydell wrote: On 25 December 2013 07:21, liguang wrote: This is where your patch should have had an explanation for why you're making this change. What is the user outside of hw/sd/ that needs this header that means we should move it into include/ ? I don't mean someone will include it outside of hw/sd, just in the sense of "header files be better in a directory called include", QEMU's policy is that header files used only by other C files within that directory can live in that directory; include is for headers which define functions to be used between modules. A10's SDHC(really an odd controller, without public datasheet) emulation will use some of definitions in this file, and I think many other standard SDHC will also be happy to include this file. I think all of these will live inside hw/sd so there's no need to move the header. OK, thanks!
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
Peter Maydell wrote: On 26 December 2013 00:14, Li Guang wrote: Peter Maydell wrote: On 25 December 2013 08:35, liguang wrote: sunxi-linux kernel parse config script to do hardware configurations Signed-off-by: liguang --- hw/arm/allwinner-a10.c | 18 ++ hw/arm/cubieboard.c|2 ++ include/hw/arm/allwinner-a10.h |5 + pc-bios/aw-script.bin | Bin 0 -> 50188 bytes What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid. it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like: [card0_boot_para] card_ctrl = 0 card_high_speed = 1 card_line = 4 sdc_d1 = port:PF00<2><1> sdc_d0 = port:PF01<2><1> sdc_clk = port:PF02<2><1> sdc_cmd = port:PF03<2><1> sdc_d3 = port:PF04<2><1> sdc_d2 = port:PF05<2><1> So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash? it's generally in /boot, bootloader will load it into ram address 0x4300, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used. Thanks and Merry Christmas! Li Guang
Re: [Qemu-devel] [PATCH] hw/sd: move sdhci.h to include/hw
On 26 December 2013 00:22, Li Guang wrote: > Peter Maydell wrote: >> On 25 December 2013 07:21, liguang wrote: >> This is where your patch should have had an explanation >> for why you're making this change. What is the user outside >> of hw/sd/ that needs this header that means we should >> move it into include/ ? > I don't mean someone will include it outside of hw/sd, just in the > sense of "header files be better in a directory called include", QEMU's policy is that header files used only by other C files within that directory can live in that directory; include is for headers which define functions to be used between modules. > A10's SDHC(really an odd controller, without public datasheet) emulation > will use some of definitions in this file, and I think many other standard > SDHC will also be happy to include this file. I think all of these will live inside hw/sd so there's no need to move the header. thanks -- PMM
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
On 26 December 2013 00:14, Li Guang wrote: > Peter Maydell wrote: >> >> On 25 December 2013 08:35, liguang wrote: >> >>> >>> sunxi-linux kernel parse config script >>> to do hardware configurations >>> >>> Signed-off-by: liguang >>> --- >>> hw/arm/allwinner-a10.c | 18 ++ >>> hw/arm/cubieboard.c|2 ++ >>> include/hw/arm/allwinner-a10.h |5 + >>> pc-bios/aw-script.bin | Bin 0 -> 50188 bytes >>> >> >> What is this? You can't just stick a 50K binary into the >> tree with no explanation, I'm afraid. >> >> > > > it's the approach sunxi-linux kernel config hardware, > the binary is actually a transformed text script, > and context of script is like: > > [card0_boot_para] > card_ctrl = 0 > card_high_speed = 1 > card_line = 4 > sdc_d1 = port:PF00<2><1> > sdc_d0 = port:PF01<2><1> > sdc_clk = port:PF02<2><1> > sdc_cmd = port:PF03<2><1> > sdc_d3 = port:PF04<2><1> > sdc_d2 = port:PF05<2><1> So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash? thanks -- PMM
Re: [Qemu-devel] [PATCH] hw/sd: move sdhci.h to include/hw
Peter Maydell wrote: On 25 December 2013 07:21, liguang wrote: This is where your patch should have had an explanation for why you're making this change. What is the user outside of hw/sd/ that needs this header that means we should move it into include/ ? I don't mean someone will include it outside of hw/sd, just in the sense of "header files be better in a directory called include", A10's SDHC(really an odd controller, without public datasheet) emulation will use some of definitions in this file, and I think many other standard SDHC will also be happy to include this file.
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
Peter Maydell wrote: On 25 December 2013 08:35, liguang wrote: sunxi-linux kernel parse config script to do hardware configurations Signed-off-by: liguang --- hw/arm/allwinner-a10.c | 18 ++ hw/arm/cubieboard.c|2 ++ include/hw/arm/allwinner-a10.h |5 + pc-bios/aw-script.bin | Bin 0 -> 50188 bytes What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid. it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like: [card0_boot_para] card_ctrl = 0 card_high_speed = 1 card_line = 4 sdc_d1 = port:PF00<2><1> sdc_d0 = port:PF01<2><1> sdc_clk = port:PF02<2><1> sdc_cmd = port:PF03<2><1> sdc_d3 = port:PF04<2><1> sdc_d2 = port:PF05<2><1> [card2_boot_para] card_ctrl = 2 card_high_speed = 1 card_line = 4 sdc_cmd = port:PC06<3><1> sdc_clk = port:PC07<3><1> sdc_d0 = port:PC08<3><1> sdc_d1 = port:PC09<3><1> sdc_d2 = port:PC10<3><1> sdc_d3 = port:PC11<3><1> [twi_para] twi_port = 0 twi_scl = port:PB00<2> twi_sda = port:PB01<2> [uart_para] uart_debug_port = 0 uart_debug_tx = port:PB22<2><1> uart_debug_rx = port:PB23<2><1>
Re: [Qemu-devel] [PATCH v3] Add DSDT node for AppleSMC
On Wed, Dec 25, 2013 at 10:33:16PM +0100, Alexander Graf wrote: > > On 25.12.2013, at 20:20, Michael S. Tsirkin wrote: > > > On Wed, Dec 25, 2013 at 08:11:56PM +0100, Alexander Graf wrote: > >> > >> > >>> Am 23.12.2013 um 04:19 schrieb "Gabriel L. Somlo" : > >>> > >>> On Sun, Dec 22, 2013 at 11:21:00PM +0100, Laszlo Ersek wrote: > > 2. Use "IRQNoFlags() { 5 }" with the SMC (or any other > > number that isn't already allocated. > > I don't think there's anything left free: > ... > > I guess the "by the book" solution would be to really stop the FDC from > being emulated when the AppleSMC is present, but I mention that idea > only because I like to waste bandwidth. > > Option 1 ("Do nothing") sounds appropriate to me. > >>> > >>> So making the FDC optional (or at least allowing it to be left out) > >>> sounds like it could be a fun project I could play with later (unless > >>> anyone else beats me to it), but it would be nice if it didn't end up > >>> a hard precondition for getting the SMC ACPI patch accepted :) > >>> > >>> Once we can turn off the FDC, we can make it and the SMC mutually > >>> exclusive and/or throw an error if both are enabled. > >>> > >>> In reality (and Alex, please correct me if I'm wrong), the emulated > >>> SMC will never generate an INT#6, unlike the real hardware chip. The > >>> emulated SMC is just there to say "Yeah, boss, sure, let me get right > >>> on that for you!" to OS X, to calm it down and make it think everything > >>> is right with its little universe :) The real chip might trigger an > >>> interrupt if something's getting too hot, or a fan stopped spinning > >>> when it shouldn't have, but that's never going to happen on a VM guest. > >> > >> Its main purpose is to signal you dropping your notebook, so the system > >> can shut down your hard drive. > >> > >> The main issue I can see with the irq line is that we now potentially have > >> two edge triggered irq sources on a single line, so an OS may get confused. > >> > >> But I agree, let's get that one solved later. > >> > >>> > >>> OS X doesn't even assume the presence of an FDC, and any guest OS > >>> which expects an FDC will never get unexpected conflicting interrupts > >>> from the emulated SMC, should the latter be enabled, accidentally or > >>> not. So in practice the risk for any trouble should be about zero... > >> > >> It may assign the irq line to the applesmc driver, killing the fdc's > >> functionality. > >> > >> Speaking of which, does the q35 even have an fdc? > >> > >> > >> Alex > > > > I don't think it does but this device seems to be supported with piix as > > well - > > or is this by mistake? > > No, the device doesn't care whether the chipset is Q35 or PIIX. Back when I > first got OSX working at all I was using PIIX because there was no Q35 > emulation available, but the Q35 is a lot closer to what Mac OS X expects > (the earliest chipset it runs on is an ICH6). > > Either way, this whole thing is optional anyway, right? I don't think anyone > will add the applesmc controller if he doesn't want to run an OSX guest, so > we should be safe. > > > Alex Yes, seems pretty safe - that's why I took this patch. If you like, send an incremental one with a comment so we remember to look as this if we ever see issues.
Re: [Qemu-devel] [PATCH v3] Add DSDT node for AppleSMC
On 25.12.2013, at 20:20, Michael S. Tsirkin wrote: > On Wed, Dec 25, 2013 at 08:11:56PM +0100, Alexander Graf wrote: >> >> >>> Am 23.12.2013 um 04:19 schrieb "Gabriel L. Somlo" : >>> >>> On Sun, Dec 22, 2013 at 11:21:00PM +0100, Laszlo Ersek wrote: > 2. Use "IRQNoFlags() { 5 }" with the SMC (or any other > number that isn't already allocated. I don't think there's anything left free: ... I guess the "by the book" solution would be to really stop the FDC from being emulated when the AppleSMC is present, but I mention that idea only because I like to waste bandwidth. Option 1 ("Do nothing") sounds appropriate to me. >>> >>> So making the FDC optional (or at least allowing it to be left out) >>> sounds like it could be a fun project I could play with later (unless >>> anyone else beats me to it), but it would be nice if it didn't end up >>> a hard precondition for getting the SMC ACPI patch accepted :) >>> >>> Once we can turn off the FDC, we can make it and the SMC mutually >>> exclusive and/or throw an error if both are enabled. >>> >>> In reality (and Alex, please correct me if I'm wrong), the emulated >>> SMC will never generate an INT#6, unlike the real hardware chip. The >>> emulated SMC is just there to say "Yeah, boss, sure, let me get right >>> on that for you!" to OS X, to calm it down and make it think everything >>> is right with its little universe :) The real chip might trigger an >>> interrupt if something's getting too hot, or a fan stopped spinning >>> when it shouldn't have, but that's never going to happen on a VM guest. >> >> Its main purpose is to signal you dropping your notebook, so the system can >> shut down your hard drive. >> >> The main issue I can see with the irq line is that we now potentially have >> two edge triggered irq sources on a single line, so an OS may get confused. >> >> But I agree, let's get that one solved later. >> >>> >>> OS X doesn't even assume the presence of an FDC, and any guest OS >>> which expects an FDC will never get unexpected conflicting interrupts >>> from the emulated SMC, should the latter be enabled, accidentally or >>> not. So in practice the risk for any trouble should be about zero... >> >> It may assign the irq line to the applesmc driver, killing the fdc's >> functionality. >> >> Speaking of which, does the q35 even have an fdc? >> >> >> Alex > > I don't think it does but this device seems to be supported with piix as well > - > or is this by mistake? No, the device doesn't care whether the chipset is Q35 or PIIX. Back when I first got OSX working at all I was using PIIX because there was no Q35 emulation available, but the Q35 is a lot closer to what Mac OS X expects (the earliest chipset it runs on is an ICH6). Either way, this whole thing is optional anyway, right? I don't think anyone will add the applesmc controller if he doesn't want to run an OSX guest, so we should be safe. Alex
Re: [Qemu-devel] [PATCH v3] Add DSDT node for AppleSMC
On Wed, Dec 25, 2013 at 08:11:56PM +0100, Alexander Graf wrote: > > > > Am 23.12.2013 um 04:19 schrieb "Gabriel L. Somlo" : > > > > On Sun, Dec 22, 2013 at 11:21:00PM +0100, Laszlo Ersek wrote: > >>>2. Use "IRQNoFlags() { 5 }" with the SMC (or any other > >>> number that isn't already allocated. > >> > >> I don't think there's anything left free: > >> ... > >> > >> I guess the "by the book" solution would be to really stop the FDC from > >> being emulated when the AppleSMC is present, but I mention that idea > >> only because I like to waste bandwidth. > >> > >> Option 1 ("Do nothing") sounds appropriate to me. > > > > So making the FDC optional (or at least allowing it to be left out) > > sounds like it could be a fun project I could play with later (unless > > anyone else beats me to it), but it would be nice if it didn't end up > > a hard precondition for getting the SMC ACPI patch accepted :) > > > > Once we can turn off the FDC, we can make it and the SMC mutually > > exclusive and/or throw an error if both are enabled. > > > > In reality (and Alex, please correct me if I'm wrong), the emulated > > SMC will never generate an INT#6, unlike the real hardware chip. The > > emulated SMC is just there to say "Yeah, boss, sure, let me get right > > on that for you!" to OS X, to calm it down and make it think everything > > is right with its little universe :) The real chip might trigger an > > interrupt if something's getting too hot, or a fan stopped spinning > > when it shouldn't have, but that's never going to happen on a VM guest. > > Its main purpose is to signal you dropping your notebook, so the system can > shut down your hard drive. > > The main issue I can see with the irq line is that we now potentially have > two edge triggered irq sources on a single line, so an OS may get confused. > > But I agree, let's get that one solved later. > > > > > OS X doesn't even assume the presence of an FDC, and any guest OS > > which expects an FDC will never get unexpected conflicting interrupts > > from the emulated SMC, should the latter be enabled, accidentally or > > not. So in practice the risk for any trouble should be about zero... > > It may assign the irq line to the applesmc driver, killing the fdc's > functionality. > > Speaking of which, does the q35 even have an fdc? > > > Alex I don't think it does but this device seems to be supported with piix as well - or is this by mistake? > > > > Thanks for helping me think this stuff through ! > > --Gabriel
Re: [Qemu-devel] [PATCH v3] Add DSDT node for AppleSMC
> Am 23.12.2013 um 04:19 schrieb "Gabriel L. Somlo" : > > On Sun, Dec 22, 2013 at 11:21:00PM +0100, Laszlo Ersek wrote: >>>2. Use "IRQNoFlags() { 5 }" with the SMC (or any other >>> number that isn't already allocated. >> >> I don't think there's anything left free: >> ... >> >> I guess the "by the book" solution would be to really stop the FDC from >> being emulated when the AppleSMC is present, but I mention that idea >> only because I like to waste bandwidth. >> >> Option 1 ("Do nothing") sounds appropriate to me. > > So making the FDC optional (or at least allowing it to be left out) > sounds like it could be a fun project I could play with later (unless > anyone else beats me to it), but it would be nice if it didn't end up > a hard precondition for getting the SMC ACPI patch accepted :) > > Once we can turn off the FDC, we can make it and the SMC mutually > exclusive and/or throw an error if both are enabled. > > In reality (and Alex, please correct me if I'm wrong), the emulated > SMC will never generate an INT#6, unlike the real hardware chip. The > emulated SMC is just there to say "Yeah, boss, sure, let me get right > on that for you!" to OS X, to calm it down and make it think everything > is right with its little universe :) The real chip might trigger an > interrupt if something's getting too hot, or a fan stopped spinning > when it shouldn't have, but that's never going to happen on a VM guest. Its main purpose is to signal you dropping your notebook, so the system can shut down your hard drive. The main issue I can see with the irq line is that we now potentially have two edge triggered irq sources on a single line, so an OS may get confused. But I agree, let's get that one solved later. > > OS X doesn't even assume the presence of an FDC, and any guest OS > which expects an FDC will never get unexpected conflicting interrupts > from the emulated SMC, should the latter be enabled, accidentally or > not. So in practice the risk for any trouble should be about zero... It may assign the irq line to the applesmc driver, killing the fdc's functionality. Speaking of which, does the q35 even have an fdc? Alex > > Thanks for helping me think this stuff through ! > --Gabriel
[Qemu-devel] [PATCH v3 2/2] acpi unit-test: extract iasl executable from configuration
The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. Signed-off-by: Marcel Apfelbaum --- v2 -> v3: - Used existing stringify() macro v1 -> v2: Addressed Michael S. Tsirkin's comments: - Stringified iasl value tests/acpi-test.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index 4f0cca6..954d9b9 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -127,6 +127,11 @@ static uint8_t boot_sector[0x7e000] = { static const char *disk = "tests/acpi-test-disk.raw"; static const char *data_dir = "tests/acpi-test-data"; +#ifdef CONFIG_IASL +static const char *iasl = stringify(CONFIG_IASL); +#else +static const char *iasl; +#endif static void free_test_data(test_data *data) { @@ -358,26 +363,6 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static bool iasl_installed(void) -{ -gchar *out = NULL, *out_err = NULL; -bool ret; - -/* pass 'out' and 'out_err' in order to be redirected */ -ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL); - -if (out_err) { -ret = ret && (out_err[0] == '\0'); -g_free(out_err); -} - -if (out) { -g_free(out); -} - -return ret; -} - static void dump_aml_files(test_data *data) { AcpiSdtTable *sdt; @@ -402,7 +387,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) { AcpiSdtTable *temp; GError *error = NULL; -GString *command_line = g_string_new("'iasl' "); +GString *command_line = g_string_new(iasl); gint fd; gchar *out, *out_err; gboolean ret; @@ -413,7 +398,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) close(fd); /* build command line */ -g_string_append_printf(command_line, "-p %s ", sdt->asl_file); +g_string_append_printf(command_line, " -p %s ", sdt->asl_file); for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */ temp = &g_array_index(sdts, AcpiSdtTable, i); g_string_append_printf(command_line, "-e %s ", temp->aml_file); @@ -567,7 +552,7 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_dsdt_table(data); test_acpi_ssdt_tables(data); -if (iasl_installed()) { +if (iasl) { test_acpi_asl(data); } -- 1.8.3.1
[Qemu-devel] [PATCH v3 1/2] configure: add CONFIG_IASL to config-host.h
Acpi unit-tests will extract iasl executable from CONFIG_IASL define. Signed-off-by: Marcel Apfelbaum --- v1 -> v2 - Removed double-quote characters around iasl value because it will be stringified in the test itself scripts/create_config | 4 1 file changed, 4 insertions(+) diff --git a/scripts/create_config b/scripts/create_config index b1adbf5..06f5316 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -26,6 +26,10 @@ case $line in # save for the next definitions prefix=${line#*=} ;; + IASL=*) # iasl executable +value=${line#*=} +echo "#define CONFIG_IASL $value" +;; CONFIG_AUDIO_DRIVERS=*) drivers=${line#*=} echo "#define CONFIG_AUDIO_DRIVERS \\" -- 1.8.3.1
[Qemu-devel] [PATCH v3 0/2] acpi unit-test: extract iasl executable from configuration
To be applied on top of: [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. patch 1: exports IASL configuration option to config-host.h patch 2: acpi uint-test uses the exported CONFIG_IASL define v2 -> v3 - Used existing stringify macro v1 -> v2 Addressed Michael S. Tsirkin's comments: - Stringified iasl macro Marcel Apfelbaum (2): configure: add CONFIG_IASL to config-host.h acpi unit-test: extract iasl executable from configuration scripts/create_config | 4 tests/acpi-test.c | 31 --- 2 files changed, 12 insertions(+), 23 deletions(-) -- 1.8.3.1
[Qemu-devel] [PATCH v2 0/2] acpi unit-test: extract iasl executable from configuration
To be applied on top of: [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. patch 1: exports IASL configuration option to config-host.h patch 2: acpi uint-test uses the exported CONFIG_IASL define v1 -> v2 Addressed Michael S. Tsirkin's comments: - Stringified iasl macro Marcel Apfelbaum (2): configure: add CONFIG_IASL to config-host.h acpi unit-test: extract iasl executable from configuration scripts/create_config | 4 tests/acpi-test.c | 35 --- 2 files changed, 16 insertions(+), 23 deletions(-) -- 1.8.3.1
[Qemu-devel] [PATCH v2 2/2] acpi unit-test: extract iasl executable from configuration
The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. Signed-off-by: Marcel Apfelbaum --- v1 -> v2: Addressed Michael S. Tsirkin's comments: - Stringified iasl value tests/acpi-test.c | 35 --- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index 4f0cca6..5e83df0 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -127,6 +127,15 @@ static uint8_t boot_sector[0x7e000] = { static const char *disk = "tests/acpi-test-disk.raw"; static const char *data_dir = "tests/acpi-test-data"; +#ifdef CONFIG_IASL + +#define IASL_STRINGIFY_(x) #x +#define IASL_STRINGIFY(x) IASL_STRINGIFY_(x) + +static const char *iasl = IASL_STRINGIFY(CONFIG_IASL); +#else +static const char *iasl; +#endif static void free_test_data(test_data *data) { @@ -358,26 +367,6 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static bool iasl_installed(void) -{ -gchar *out = NULL, *out_err = NULL; -bool ret; - -/* pass 'out' and 'out_err' in order to be redirected */ -ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL); - -if (out_err) { -ret = ret && (out_err[0] == '\0'); -g_free(out_err); -} - -if (out) { -g_free(out); -} - -return ret; -} - static void dump_aml_files(test_data *data) { AcpiSdtTable *sdt; @@ -402,7 +391,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) { AcpiSdtTable *temp; GError *error = NULL; -GString *command_line = g_string_new("'iasl' "); +GString *command_line = g_string_new(iasl); gint fd; gchar *out, *out_err; gboolean ret; @@ -413,7 +402,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) close(fd); /* build command line */ -g_string_append_printf(command_line, "-p %s ", sdt->asl_file); +g_string_append_printf(command_line, " -p %s ", sdt->asl_file); for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */ temp = &g_array_index(sdts, AcpiSdtTable, i); g_string_append_printf(command_line, "-e %s ", temp->aml_file); @@ -567,7 +556,7 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_dsdt_table(data); test_acpi_ssdt_tables(data); -if (iasl_installed()) { +if (iasl) { test_acpi_asl(data); } -- 1.8.3.1
[Qemu-devel] [PATCH v2 1/2] configure: add CONFIG_IASL to config-host.h
Acpi unit-tests will extract iasl executable from CONFIG_IASL define. Signed-off-by: Marcel Apfelbaum --- v1 -> v2 - Removed double-quote characters around iasl value because it will be stringified in the test itself scripts/create_config | 4 1 file changed, 4 insertions(+) diff --git a/scripts/create_config b/scripts/create_config index b1adbf5..06f5316 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -26,6 +26,10 @@ case $line in # save for the next definitions prefix=${line#*=} ;; + IASL=*) # iasl executable +value=${line#*=} +echo "#define CONFIG_IASL $value" +;; CONFIG_AUDIO_DRIVERS=*) drivers=${line#*=} echo "#define CONFIG_AUDIO_DRIVERS \\" -- 1.8.3.1
Re: [Qemu-devel] [PATCH] virtio: Fix return value for dummy function vhost_net_virtqueue_pending
On Sun, Dec 22, 2013 at 03:51:22PM +0100, Stefan Weil wrote: > cgcc complains that -ENOSYS is not a good value for 'bool'. > > A dummy virtio will never have pending queue entries, so let us return > false. > > Signed-off-by: Stefan Weil Applied, thanks. > --- > > Could we also use g_assert_not_reached or hw_error in those dummy functions? > > Regards > Stefan I'd go for g_assert_not_reached normally - it's an internal bug if this is called since init stub fails. Or leave it as is - it's an unusual configuration. > hw/net/vhost_net.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index 006576d..854997d 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -321,7 +321,7 @@ void vhost_net_ack_features(struct vhost_net *net, > unsigned features) > > bool vhost_net_virtqueue_pending(VHostNetState *net, int idx) > { > -return -ENOSYS; > +return false; > } > > void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, > -- > 1.7.10.4
Re: [Qemu-devel] [PATCH 1/2] configure: add CONFIG_IASL to config-host.h
On Wed, Dec 25, 2013 at 12:50:15PM +0200, Marcel Apfelbaum wrote: > Acpi unit-tests will extract the iasl executable > from CONFIG_IASL define. > > Signed-off-by: Marcel Apfelbaum > --- > scripts/create_config | 4 > 1 file changed, 4 insertions(+) > > diff --git a/scripts/create_config b/scripts/create_config > index b1adbf5..0478315 100755 > --- a/scripts/create_config > +++ b/scripts/create_config > @@ -26,6 +26,10 @@ case $line in > # save for the next definitions > prefix=${line#*=} > ;; > + IASL=*) # iasl executable > +value=${line#*=} > +echo "#define CONFIG_IASL \"$value\"" > +;; This won't work correctly if IASL includes any special characters like \ or '. It's a good idea to use preprocessor's # operator, that escapes them properly. We have a bunch of macros like this all over the place, short term you can introduce #define CONFIG_STRINGIFY(x) #x longer term we really want QEMU_STRINGIFY. > CONFIG_AUDIO_DRIVERS=*) > drivers=${line#*=} > echo "#define CONFIG_AUDIO_DRIVERS \\" > -- > 1.8.3.1
Re: [Qemu-devel] [PATCH v3] Add DSDT node for AppleSMC
On Sun, Dec 22, 2013 at 10:34:56AM -0500, Gabriel L. Somlo wrote: > AppleSMC (-device isa-applesmc) is required to boot OS X guests. > OS X expects a SMC node to be present in the ACPI DSDT. This patch > adds a SMC node to the DSDT, and dynamically patches the return value > of SMC._STA to either 0x0B if the chip is present, or otherwise to 0x00, > before booting the guest. > > Signed-off-by: Gabriel Somlo Applied, thanks. > --- > > On Sun, Dec 22, 2013 at 01:07:13PM +0200, Michael S. Tsirkin wrote: > >> +#define _CONCAT_SYM(a, b) a##b > >> +#define CONCAT_SYM(a, b) _CONCAT_SYM(a, b) > > > > Seems too complex. If one looks for q35_smc_sta one can not find it > > You're right, I went all "Rube Goldberg" on that one - thanks for > pulling me back from the edge :) > > >> +unsigned short smc_sta_val = 0x00; > > > > Better initialize this in the else branch below. > > I threw in "applesmc_find()" to make that even cleaner and easier to > follow. > > Thanks, > Gabriel > > hw/misc/applesmc.c| 1 - > include/hw/isa/isa.h | 7 +++ > hw/i386/acpi-dsdt.dsl | 1 + > hw/i386/q35-acpi-dsdt.dsl | 1 + > hw/i386/acpi-dsdt-isa.dsl | 11 +++ > hw/i386/acpi-build.c | 9 + > 6 files changed, 29 insertions(+), 1 deletion(-) > > diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c > index 1e8d183..627adb9 100644 > --- a/hw/misc/applesmc.c > +++ b/hw/misc/applesmc.c > @@ -66,7 +66,6 @@ struct AppleSMCData { > QLIST_ENTRY(AppleSMCData) node; > }; > > -#define TYPE_APPLE_SMC "isa-applesmc" > #define APPLE_SMC(obj) OBJECT_CHECK(AppleSMCState, (obj), TYPE_APPLE_SMC) > > typedef struct AppleSMCState AppleSMCState; > diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h > index fa45a5b..e0c749f 100644 > --- a/include/hw/isa/isa.h > +++ b/include/hw/isa/isa.h > @@ -20,6 +20,13 @@ > #define TYPE_ISA_BUS "ISA" > #define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS) > > +#define TYPE_APPLE_SMC "isa-applesmc" > + > +static inline bool applesmc_find(void) > +{ > +return object_resolve_path_type("", TYPE_APPLE_SMC, NULL); > +} > + > typedef struct ISADeviceClass { > DeviceClass parent_class; > } ISADeviceClass; > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl > index a377424..b87c6e0 100644 > --- a/hw/i386/acpi-dsdt.dsl > +++ b/hw/i386/acpi-dsdt.dsl > @@ -114,6 +114,7 @@ DefinitionBlock ( > } > } > > +#define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta > #include "acpi-dsdt-isa.dsl" > > > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl > index 575c5d7..12ff544 100644 > --- a/hw/i386/q35-acpi-dsdt.dsl > +++ b/hw/i386/q35-acpi-dsdt.dsl > @@ -171,6 +171,7 @@ DefinitionBlock ( > } > } > > +#define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta > #include "acpi-dsdt-isa.dsl" > > > diff --git a/hw/i386/acpi-dsdt-isa.dsl b/hw/i386/acpi-dsdt-isa.dsl > index 89caa16..46942c1 100644 > --- a/hw/i386/acpi-dsdt-isa.dsl > +++ b/hw/i386/acpi-dsdt-isa.dsl > @@ -16,6 +16,17 @@ > /* Common legacy ISA style devices. */ > Scope(\_SB.PCI0.ISA) { > > +Device (SMC) { > +Name(_HID, EisaId("APP0001")) > +/* _STA will be patched to 0x0B if AppleSMC is present */ > +ACPI_EXTRACT_NAME_WORD_CONST DSDT_APPLESMC_STA > +Name(_STA, 0xFF00) > +Name(_CRS, ResourceTemplate () { > +IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) > +IRQNoFlags() { 6 } > +}) > +} > + > Device(RTC) { > Name(_HID, EisaId("PNP0B00")) > Name(_CRS, ResourceTemplate() { > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 48312f5..30bfcd2 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -36,6 +36,7 @@ > #include "hw/nvram/fw_cfg.h" > #include "bios-linker-loader.h" > #include "hw/loader.h" > +#include "hw/isa/isa.h" > > /* Supported chipsets: */ > #include "hw/acpi/piix4.h" > @@ -80,6 +81,7 @@ typedef struct AcpiMiscInfo { > > static void acpi_get_dsdt(AcpiMiscInfo *info) > { > +unsigned short applesmc_sta_val, *applesmc_sta_off; > Object *piix = piix4_pm_find(); > Object *lpc = ich9_lpc_find(); > assert(!!piix != !!lpc); > @@ -87,11 +89,18 @@ static void acpi_get_dsdt(AcpiMiscInfo *info) > if (piix) { > info->dsdt_code = AcpiDsdtAmlCode; > info->dsdt_size = sizeof AcpiDsdtAmlCode; > +applesmc_sta_off = piix_dsdt_applesmc_sta; > } > if (lpc) { > info->dsdt_code = Q35AcpiDsdtAmlCode; > info->dsdt_size = sizeof Q35AcpiDsdtAmlCode; > +applesmc_sta_off = q35_dsdt_applesmc_sta; > } > + > +/* Patch in appropriate value for AppleSMC _STA */ > +applesmc_sta_val = applesmc_find() ? 0x0b : 0x00; > +*(uint16_t *)(info->dsdt_code + *applesmc_sta_off) = > +cpu_to_le16(applesmc_sta_val); > } > > static > -- > 1.8.1.4
Re: [Qemu-devel] [PATCH 1/2] configure: add CONFIG_IASL to config-host.h
On Wed, 2013-12-25 at 12:50 +0200, Marcel Apfelbaum wrote: > Acpi unit-tests will extract the iasl executable > from CONFIG_IASL define. > > Signed-off-by: Marcel Apfelbaum Added the maintainers of scripts/create_config, sorry for not doing it in the first place. Thanks, Marcel > --- > scripts/create_config | 4 > 1 file changed, 4 insertions(+) > > diff --git a/scripts/create_config b/scripts/create_config > index b1adbf5..0478315 100755 > --- a/scripts/create_config > +++ b/scripts/create_config > @@ -26,6 +26,10 @@ case $line in > # save for the next definitions > prefix=${line#*=} > ;; > + IASL=*) # iasl executable > +value=${line#*=} > +echo "#define CONFIG_IASL \"$value\"" > +;; > CONFIG_AUDIO_DRIVERS=*) > drivers=${line#*=} > echo "#define CONFIG_AUDIO_DRIVERS \\"
[Qemu-devel] [PATCH 1/2] configure: add CONFIG_IASL to config-host.h
Acpi unit-tests will extract the iasl executable from CONFIG_IASL define. Signed-off-by: Marcel Apfelbaum --- scripts/create_config | 4 1 file changed, 4 insertions(+) diff --git a/scripts/create_config b/scripts/create_config index b1adbf5..0478315 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -26,6 +26,10 @@ case $line in # save for the next definitions prefix=${line#*=} ;; + IASL=*) # iasl executable +value=${line#*=} +echo "#define CONFIG_IASL \"$value\"" +;; CONFIG_AUDIO_DRIVERS=*) drivers=${line#*=} echo "#define CONFIG_AUDIO_DRIVERS \\" -- 1.8.3.1
[Qemu-devel] [PATCH 0/2] acpi unit-test: extract iasl executable from configuration
The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. patch 1: exports IASL configuration option to config-host.h patch 2: acpi unit-test uses the exported CONFIG_IASL define Marcel Apfelbaum (2): configure: add CONFIG_IASL to config-host.h acpi unit-test: extract iasl executable from configuration scripts/create_config | 4 tests/acpi-test.c | 31 --- 2 files changed, 12 insertions(+), 23 deletions(-) -- 1.8.3.1
[Qemu-devel] [PATCH 2/2] acpi unit-test: extract iasl executable from configuration
The test checked if iasl is installed by running "iasl" and checking the error output. It is better to use the iasl executable as appears in configuration. Signed-off-by: Marcel Apfelbaum --- tests/acpi-test.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index 4f0cca6..d9374f2 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -127,6 +127,11 @@ static uint8_t boot_sector[0x7e000] = { static const char *disk = "tests/acpi-test-disk.raw"; static const char *data_dir = "tests/acpi-test-data"; +#ifdef CONFIG_IASL +static const char *iasl = CONFIG_IASL; +#else +static const char *iasl; +#endif static void free_test_data(test_data *data) { @@ -358,26 +363,6 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static bool iasl_installed(void) -{ -gchar *out = NULL, *out_err = NULL; -bool ret; - -/* pass 'out' and 'out_err' in order to be redirected */ -ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL); - -if (out_err) { -ret = ret && (out_err[0] == '\0'); -g_free(out_err); -} - -if (out) { -g_free(out); -} - -return ret; -} - static void dump_aml_files(test_data *data) { AcpiSdtTable *sdt; @@ -402,7 +387,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) { AcpiSdtTable *temp; GError *error = NULL; -GString *command_line = g_string_new("'iasl' "); +GString *command_line = g_string_new(iasl); gint fd; gchar *out, *out_err; gboolean ret; @@ -413,7 +398,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) close(fd); /* build command line */ -g_string_append_printf(command_line, "-p %s ", sdt->asl_file); +g_string_append_printf(command_line, " -p %s ", sdt->asl_file); for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */ temp = &g_array_index(sdts, AcpiSdtTable, i); g_string_append_printf(command_line, "-e %s ", temp->aml_file); @@ -567,7 +552,7 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_dsdt_table(data); test_acpi_ssdt_tables(data); -if (iasl_installed()) { +if (iasl) { test_acpi_asl(data); } -- 1.8.3.1
Re: [Qemu-devel] examples or tutorial/docs for writing block drivers for qemu
2013/12/24 Hani Benhabiles : > > I haven't taken the time to look at it yet, but there is a talk from this > year's > KVM Forum (Implementing New Block Drivers: A QEMU Developer Primer - Jeff > Cody) > that could help you. Thank you! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru jabber: v...@selfip.ru
Re: [Qemu-devel] vhost-net issue: does not survive reboot on ppc64
On Wed, Dec 25, 2013 at 12:36:12PM +1100, Alexey Kardashevskiy wrote: > On 12/25/2013 02:43 AM, Michael S. Tsirkin wrote: > > On Wed, Dec 25, 2013 at 01:15:29AM +1100, Alexey Kardashevskiy wrote: > >> On 12/24/2013 08:40 PM, Michael S. Tsirkin wrote: > >>> On Tue, Dec 24, 2013 at 02:09:07PM +1100, Alexey Kardashevskiy wrote: > On 12/24/2013 03:24 AM, Michael S. Tsirkin wrote: > > On Mon, Dec 23, 2013 at 02:01:13AM +1100, Alexey Kardashevskiy wrote: > >> On 12/23/2013 01:46 AM, Alexey Kardashevskiy wrote: > >>> On 12/22/2013 09:56 PM, Michael S. Tsirkin wrote: > On Sun, Dec 22, 2013 at 02:01:23AM +1100, Alexey Kardashevskiy wrote: > > Hi! > > > > I am having a problem with virtio-net + vhost on POWER7 machine - > > it does > > not survive reboot of the guest. > > > > Steps to reproduce: > > 1. boot the guest > > 2. configure eth0 and do ping - everything works > > 3. reboot the guest (i.e. type "reboot") > > 4. when it is booted, eth0 can be configured but will not work at > > all. > > > > The test is: > > ifconfig eth0 172.20.1.2 up > > ping 172.20.1.23 > > > > If to run tcpdump on the host's "tap-id3" interface, it shows no > > trafic > > coming from the guest. If to compare how it works before and after > > reboot, > > I can see the guest doing an ARP request for 172.20.1.23 and > > receives the > > response and it does the same after reboot but the answer does not > > come. > > So you see the arp packet in guest but not in host? > >>> > >>> Yes. > >>> > >>> > One thing to try is to boot debug kernel - where pr_debug is > enabled - then you might see some errors in the kernel log. > >>> > >>> Tried and added lot more debug printk myself, not clear at all what is > >>> happening there. > >>> > >>> One more hint - if I boot the guest and the guest does not bring eth0 > >>> up > >>> AND wait more than 200 seconds (and less than 210 seconds), then eth0 > >>> will > >>> not work at all. I.e. this script produces not-working-eth0: > >>> > >>> > >>> ifconfig eth0 172.20.1.2 down > >>> sleep 210 > >>> ifconfig eth0 172.20.1.2 up > >>> ping 172.20.1.23 > >>> > >>> s/210/200/ - and it starts working. No reboot is required to > >>> reproduce. > >>> > >>> No "vhost" == always works. The only difference I can see here is > >>> vhost's > >>> thread which may get suspended if not used for a while after the > >>> start and > >>> does not wake up but this is almost a blind guess. > >> > >> > >> Yet another clue - this host kernel patch seems to help with the guest > >> reboot but does not help with the initial 210 seconds delay: > >> > >> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > >> index 69068e0..5e67650 100644 > >> --- a/drivers/vhost/vhost.c > >> +++ b/drivers/vhost/vhost.c > >> @@ -162,10 +162,10 @@ void vhost_work_queue(struct vhost_dev *dev, > >> struct > >> vhost_work *work) > >> list_add_tail(&work->node, &dev->work_list); > >> work->queue_seq++; > >> spin_unlock_irqrestore(&dev->work_lock, flags); > >> - wake_up_process(dev->worker); > >> } else { > >> spin_unlock_irqrestore(&dev->work_lock, flags); > >> } > >> + wake_up_process(dev->worker); > >> } > >> EXPORT_SYMBOL_GPL(vhost_work_queue); > >> > >> > > > > Interesting. Some kind of race? A missing memory barrier somewhere? > > I do not see how. I boot the guest and just wait 210 seconds, nothing > happens to cause races. > > > > Since it's all around startup, > > you can try kicking the host eventfd in > > vhost_net_start. > > > How exactly? This did not help. Thanks. > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index 006576d..407ecf2 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -229,6 +229,17 @@ int vhost_net_start(VirtIODevice *dev, > NetClientState > *ncs, > if (r < 0) { > goto err; > } > + > +VHostNetState *vn = tap_get_vhost_net(ncs[i].peer); > +struct vhost_vring_file file = { > +.index = i > +}; > +file.fd = > event_notifier_get_fd(virtio_queue_get_host_notifier(dev->vq)); > +r = ioctl(vn->dev.control, VHOST_SET_VRING_KICK, &file); > >>> > >>> No, this sets the notifier, it does not kick. > >>> To kick you write 1 there: > >>> uint6_t v = 1; > >>> write(fd, &v, sizeof v); > >> > >> > >> P
Re: [Qemu-devel] [PATCH] hw/sd: move sdhci.h to include/hw
On 25 December 2013 07:21, liguang wrote: This is where your patch should have had an explanation for why you're making this change. What is the user outside of hw/sd/ that needs this header that means we should move it into include/ ? > Signed-off-by: liguang thanks -- PMM
Re: [Qemu-devel] [PATCH] allwinner-a10: add config script support
On 25 December 2013 08:35, liguang wrote: > sunxi-linux kernel parse config script > to do hardware configurations > > Signed-off-by: liguang > --- > hw/arm/allwinner-a10.c | 18 ++ > hw/arm/cubieboard.c|2 ++ > include/hw/arm/allwinner-a10.h |5 + > pc-bios/aw-script.bin | Bin 0 -> 50188 bytes What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid. thanks -- PMM
[Qemu-devel] [PATCH] allwinner-a10: add config script support
sunxi-linux kernel parse config script to do hardware configurations Signed-off-by: liguang --- hw/arm/allwinner-a10.c | 18 ++ hw/arm/cubieboard.c|2 ++ include/hw/arm/allwinner-a10.h |5 + pc-bios/aw-script.bin | Bin 0 -> 50188 bytes 4 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 pc-bios/aw-script.bin diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 4658e19..b189897 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -18,6 +18,7 @@ #include "hw/sysbus.h" #include "hw/devices.h" #include "hw/arm/allwinner-a10.h" +#include "hw/loader.h" static void aw_a10_init(Object *obj) { @@ -33,6 +34,23 @@ static void aw_a10_init(Object *obj) qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default()); } + void aw_a10_load_script(const char *s) +{ +char *file_name; +int file_size; + +file_name = qemu_find_file(QEMU_FILE_TYPE_BIOS, s); +file_size = get_image_size(file_name); +if (file_size < 0) { +error_report("%s size is wrong\n", AW_CONFIG_SCRIPT); +return; +} +if (load_image_targphys(file_name, AW_SCRIPT_ADDR, file_size) < 0) { +error_report("can't load %s\n", AW_CONFIG_SCRIPT); +return; +} +} + static void aw_a10_realize(DeviceState *dev, Error **errp) { AwA10State *s = AW_A10(dev); diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 3fcb6d2..888256e 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -48,6 +48,8 @@ static void cubieboard_init(QEMUMachineInitArgs *args) memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE, &s->sdram); +aw_a10_load_script(AW_CONFIG_SCRIPT); + cubieboard_binfo.ram_size = args->ram_size; cubieboard_binfo.kernel_filename = args->kernel_filename; cubieboard_binfo.kernel_cmdline = args->kernel_cmdline; diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h index da36647..d395067 100644 --- a/include/hw/arm/allwinner-a10.h +++ b/include/hw/arm/allwinner-a10.h @@ -17,6 +17,9 @@ #define AW_A10_SDRAM_BASE 0x4000 +#define AW_CONFIG_SCRIPT"aw-script.bin" +#define AW_SCRIPT_ADDR 0x4300 + #define TYPE_AW_A10 "allwinner-a10" #define AW_A10(obj) OBJECT_CHECK(AwA10State, (obj), TYPE_AW_A10) @@ -31,5 +34,7 @@ typedef struct AwA10State { AwA10PICState intc; } AwA10State; +void aw_a10_load_script(const char *s); + #define ALLWINNER_H_ #endif diff --git a/pc-bios/aw-script.bin b/pc-bios/aw-script.bin new file mode 100644 index ..47bca6ff62695aca99ca4b9f2c6d74e98828b062 GIT binary patch literal 50188 zcmbuI37BM6b;s`v42&$pHVOjgTxolZRtL60SblcU1Nj)etCwtPSc{C zLp+WpxY{k7#Bg8$(xpAG_XCoeO2xYd*lRIb@Rz}*6_XVrpol(=^24FHaEH>{Uz-{mYu8otx{`T0NtO0k@fP zT7yF#Tm`OUCjxb8?nlJ!tk0V5oVpBm#q%j&s`YlsfZ@Mqh$H`5m~U@WFK}+$oaHzN z|6M@boY^~P^Tf9i*RZSW;J^EctF)V)a!-eSe^1mtO#&l`#B zb*lAQqiLet_YzlLfTQhx?IGyfS?^cobrAjYS74ttXc2>P>q+7owW?VW8hYJ-5!Y!h z=!FuqkzU)@I@hgL+KaXBt`aq55)~Gdd*iV*4ld62O8xRoLvBXy5aK>W++4?Wi#wON zi(lv*mD#JeTZQtXV4veLH(pNj-O7Bur4&l=zQpZC91U*0+H9jd7ZoJy{k*v14+&hS(ZJBIE{6^|Wk#HBdf1SgQkBsctB0I2)6KSi?vR_d^gSi);pfePga0ZK&)|9$E$eB&gX!y4i^p+dzO(}8_xJq~l~PA4z8}hETz@GlVe5sWzOKam zYLOGmee)ic`<9|UvD~)@&L1DDwbTLgouORMHG8av`M2-l`ivuSH*l`n&MRS`{xHYY z**E#O?+YCDqpj-9u2QpI6~~W1ArATCk6+Eu7+kJayLnaq)1PwA=!kCPoHl5Y#t(6> zTW)PHwHBm^Y8r*&EPB%Ib|-J5V)m-VrP z(#jv>_=DF&nGUk5Dxn{MZU~bt7EN)HO7gfN0IoDrOdJX3e%yVje z593^=tM+S0<~VgX${oYGZmp-ClR7SNG%pz`8F_ySabf;4VohMyaec-FW^BlfTIEg; z%N@1K-N5x3<(@g@#;kJB9hN(0mAi%OGs@i>I6n_F{Jbrco1MpzW^`FXUc@f$Pvzc{<0|To*Nm z>ee*E?L!>e2VE~vs`N@T^?tM5DfG^CygkQhvu8Tz!pg1mwAr|Gs~AVeo74l8s~Oj9 z_tXOyYdBZ$Y13l2mT^XS-SNcjiC<30ak^hlWaV0ZIhApiUnUr5`DG*L48Lq*oaL7- z#O;Y+&dYJSUtY?}wfyo5##w&3m~ob0uHc;Em)9}Q^2;o7d*YY59H;wbo|S9)rNubQ zFMY;YetA9T48Oc7aJb&b^2^(ZgI~b4=vow^Yw@DrAZ|JRfx|KAx-z5uO{Nc=a@f)R z7UO!AZmrfTHOot-LdSZo%%z73-8&f9tpQPwT)jmn$CX{P>xsj0ANYA^d3$Z4BS+*W##L*5HO4oGa%cOKOC^0; z=iVE*x&HK6AqdQbKZ;zhaoNrE7h1oOYC&t})7S+R=8pW-iBRN870nKPk&opD$JYQh=2?PQMgj73X#; zofXAxHRmcd)iG=Goa&ghc}{iA@x(2otBrhpD>c9Z)iEb=jwbJDgVJ&` zap*U^eXZ&a?Lg8<;O5$Gx}F~w|ChSue(~_~lrNXg`^D>H>4cPYvU5G>w3CQr@O0p^ zF?s|Szjo-t(ZZh62AL~p-k9S?Redj(xq`ma12;P}Qktb}_35_(v$M5s;jH5soTJ}i zl$DWo49C=W(vmZuRLpF`-!ZQqIvu#tS~{ zi|1I+=iK~460Kp&yI{ysJ#_nC#yP{jt(-ILdpYL}`(82R)Hxk$b0Oob`PwTPSC}*p z-Qr%wxGL@MQ?k}}u7eR0Am#kxxpuA`i~x|DI) zq0mD7YR=Im?izO)r5qiJ zlP)otO*y(|rP6Kp(s6x`ah1-3SXa1ao^iAK?xm|U4n@w+$y4L27&ljLHp`_-yGs`v z(^R6xuU*+*;QBL-Qc-6^@4)qy(AI`m%aYgSAE&MIUsgrEN zuVb7#$tLbb#!U>1DZG0RYpE6FJWD|EMGvcxQ9W&ywl5<8pRt-7hED7!Z4mtUP&5&7ZhTME_S4+LlXzh?&w7BDk zoZ45R=yk;5I57H2Yd-lR##!^pQyFK?Cr@LXHJ=}zaN2zG%!JeClbaZ4%_q-FIb}Y%Ipvi3^{*oH^gUlDJS0>*rRk%s9m~ zUynJ)DW-X@$v9(r<$8=WrdMtkizx&YJJu#5pBb z;J}+XX9VO{&KUu@jdMmo?&6#gkb6021mu&PGXnDGoHGLQ*PJr~@_EKt^W86T&WOij zoHOF_b__|}j!=eti2Idi`Iy&-4LcYi$O%=zxm0*4!PX#3{K)4fi~=DWnv_2^x7 zp1t>wqwB|YZpDzJ>%DbupCLDHar*|&-$%r#$jZQ__Yp}e|D3?J7