[Qemu-devel] peter.mayd...@linaro.org
Hi all, According to 2.9 changelog page, DragonFly BSD will be listed as unsupported with the possibility of dropping support completely in the future: http://wiki.qemu.org/ChangeLog/2.9 I'd like to volunteer so that qemu can keep DragonFly BSD as a supported platform. Could you please let me know the requirements needed to do so? Best regards, Antonio Huete
[Qemu-devel] DragonFly BSD support
Hi all, According to 2.9 changelog page, DragonFly BSD will be listed as unsupported with the possibility of dropping support completely in the future: http://wiki.qemu.org/ChangeLog/2.9 I'd like to volunteer so that qemu can keep DragonFly BSD as a supported platform. Could you please let me know the requirements needed to do so? Best regards, Antonio Huete
[Qemu-devel] [PATCH] sockets: Normalize test for addrinfo flag AI_V4MAPPED
From 2b4d9d8cb617445af8f3b062f917dfea42dbdc27 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 2 Nov 2017 17:46:24 +0100 Subject: [PATCH] sockets: Normalize test for addrinfo flag AI_V4MAPPED Signed-off-by: Antonio Huete Jimenez --- util/qemu-sockets.c | 54 + 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index b47fb45885..ce35b6a998 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -44,7 +44,6 @@ # define AI_NUMERICSERV 0 #endif - static int inet_getport(struct addrinfo *e) { struct sockaddr_in *i4; @@ -149,6 +148,31 @@ int inet_ai_family_from_address(InetSocketAddress *addr, return PF_UNSPEC; } +static int +check_ai_v4mapped(const char *host, const char *port, struct addrinfo *ai, + struct addrinfo *res) +{ +static int useV4Mapped = -1; +int rc; + +/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but + * then don't implement it in their getaddrinfo(). + * Unconditionally deselect AI_V4MAPPED option upon + * getaddrinfo() failure, the next call to it will have to + * do the error handling. + */ +if (atomic_read(&useV4Mapped) == -1) { +rc = getaddrinfo(host, port, ai, &res); +if (rc == 0 && (ai->ai_flags & AI_V4MAPPED)) { +atomic_set(&useV4Mapped, 1); +} else { +atomic_set(&useV4Mapped, 0); +} +} + +return useV4Mapped; +} + static int create_fast_reuse_socket(struct addrinfo *e) { int slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol); @@ -378,14 +402,10 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, struct addrinfo ai, *res; int rc; Error *err = NULL; -static int useV4Mapped = 1; memset(&ai, 0, sizeof(ai)); -ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; -if (atomic_read(&useV4Mapped)) { -ai.ai_flags |= AI_V4MAPPED; -} +ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG | AI_V4MAPPED; ai.ai_family = inet_ai_family_from_address(saddr, &err); ai.ai_socktype = SOCK_STREAM; @@ -399,21 +419,11 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, return NULL; } -/* lookup */ -rc = getaddrinfo(saddr->host, saddr->port, &ai, &res); - -/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but - * then don't implement it in their getaddrinfo(). Detect - * this and retry without the flag since that's preferrable - * to a fatal error - */ -if (rc == EAI_BADFLAGS && -(ai.ai_flags & AI_V4MAPPED)) { -atomic_set(&useV4Mapped, 0); +if ((check_ai_v4mapped(saddr->host, saddr->port, &ai, res)) == 0) { ai.ai_flags &= ~AI_V4MAPPED; -rc = getaddrinfo(saddr->host, saddr->port, &ai, &res); } -if (rc != 0) { + +if ((rc = getaddrinfo(saddr->host, saddr->port, &ai, &res)) != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", saddr->host, saddr->port, gai_strerror(rc)); return NULL; @@ -469,7 +479,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, /* lookup peer addr */ memset(&ai,0, sizeof(ai)); -ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; +ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG | AI_V4MAPPED; ai.ai_family = inet_ai_family_from_address(sraddr, &err); ai.ai_socktype = SOCK_DGRAM; @@ -488,6 +498,10 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, goto err; } +if ((check_ai_v4mapped(addr, port, &ai, &peer)) == 0) { +ai.ai_flags &= ~AI_V4MAPPED; +} + if ((rc = getaddrinfo(addr, port, &ai, &peer)) != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", addr, port, gai_strerror(rc)); -- 2.14.1
Re: [Qemu-devel] [PATCH] sockets: Normalize test for addrinfo flag AI_V4MAPPED
"Daniel P. Berrange" escribió: On Thu, Nov 02, 2017 at 04:56:29PM +0000, Antonio Huete Jiménez wrote: From 2b4d9d8cb617445af8f3b062f917dfea42dbdc27 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 2 Nov 2017 17:46:24 +0100 Subject: [PATCH] sockets: Normalize test for addrinfo flag AI_V4MAPPED Can you explain why you're making this change Hi Daniel, Thanks for reviewing the patch. I am trying to fix 'make check' for DragonFly BSD and this is the first issue I encountered. With help from people in #qemu we found that it may be necessary to consistently check for the availability of this flag so I thought it would be a good idea to do it like this. Signed-off-by: Antonio Huete Jimenez --- util/qemu-sockets.c | 54 + 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index b47fb45885..ce35b6a998 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -44,7 +44,6 @@ # define AI_NUMERICSERV 0 #endif - static int inet_getport(struct addrinfo *e) { struct sockaddr_in *i4; @@ -149,6 +148,31 @@ int inet_ai_family_from_address(InetSocketAddress *addr, return PF_UNSPEC; } +static int +check_ai_v4mapped(const char *host, const char *port, struct addrinfo *ai, + struct addrinfo *res) +{ +static int useV4Mapped = -1; +int rc; + +/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but + * then don't implement it in their getaddrinfo(). + * Unconditionally deselect AI_V4MAPPED option upon + * getaddrinfo() failure, the next call to it will have to + * do the error handling. + */ +if (atomic_read(&useV4Mapped) == -1) { +rc = getaddrinfo(host, port, ai, &res); +if (rc == 0 && (ai->ai_flags & AI_V4MAPPED)) { +atomic_set(&useV4Mapped, 1); +} else { +atomic_set(&useV4Mapped, 0); +} +} + +return useV4Mapped; +} + static int create_fast_reuse_socket(struct addrinfo *e) { int slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol); @@ -378,14 +402,10 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, struct addrinfo ai, *res; int rc; Error *err = NULL; -static int useV4Mapped = 1; memset(&ai, 0, sizeof(ai)); -ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; -if (atomic_read(&useV4Mapped)) { -ai.ai_flags |= AI_V4MAPPED; -} +ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG | AI_V4MAPPED; ai.ai_family = inet_ai_family_from_address(saddr, &err); ai.ai_socktype = SOCK_STREAM; @@ -399,21 +419,11 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, return NULL; } -/* lookup */ -rc = getaddrinfo(saddr->host, saddr->port, &ai, &res); - -/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but - * then don't implement it in their getaddrinfo(). Detect - * this and retry without the flag since that's preferrable - * to a fatal error - */ -if (rc == EAI_BADFLAGS && -(ai.ai_flags & AI_V4MAPPED)) { -atomic_set(&useV4Mapped, 0); +if ((check_ai_v4mapped(saddr->host, saddr->port, &ai, res)) == 0) { ai.ai_flags &= ~AI_V4MAPPED; -rc = getaddrinfo(saddr->host, saddr->port, &ai, &res); } -if (rc != 0) { + +if ((rc = getaddrinfo(saddr->host, saddr->port, &ai, &res)) != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", saddr->host, saddr->port, gai_strerror(rc)); return NULL; @@ -469,7 +479,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, /* lookup peer addr */ memset(&ai,0, sizeof(ai)); -ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; +ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG | AI_V4MAPPED; Gratuitous re-ordering of code with no functional change. Agree, can change it. ai.ai_family = inet_ai_family_from_address(sraddr, &err); ai.ai_socktype = SOCK_DGRAM; @@ -488,6 +498,10 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, goto err; } +if ((check_ai_v4mapped(addr, port, &ai, &peer)) == 0) { +ai.ai_flags &= ~AI_V4MAPPED; +} + if ((rc = getaddrinfo(addr, port, &ai, &peer)) != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", addr, port, gai_strerror(rc)); -- 2.14.1 Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org-o- https://www.instagram.com/dberrange :|
[Qemu-devel] [PATCH] test/i386 - Allow TCG to boot with > 1TB memory
From daea6caf8d9e023d06a825a774b678d26d978209 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Tue, 12 Dec 2017 19:17:49 +0100 Subject: [PATCH] test/i386 - Allow TCG to boot with > 1TB memory. Currently for TCG the cpu 'phys_bits' property can't be specified as it is hardcoded to be either 36 or 40 bits. This patch lets the user specify the physical address bits for the cpu as long as it's between a defined range. It will fallback to 'default' values which are the current ones so the behaviour when the property isn't specified remains as it is now. Signed-off-by: Antonio Huete Jimenez --- target/i386/cpu.c | 11 +++ target/i386/cpu.h | 15 +-- target/i386/excp_helper.c | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 045d66191f..63da043027 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3687,9 +3687,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) return; } } else { -if (cpu->phys_bits && cpu->phys_bits != TCG_PHYS_ADDR_BITS) { -error_setg(errp, "TCG only supports phys-bits=%u", - TCG_PHYS_ADDR_BITS); +if (cpu->phys_bits && +(cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS || + cpu->phys_bits < 32)) { +error_setg(errp, "phys-bits should be between 32 and %u " + " (but is %u)", + TARGET_PHYS_ADDR_SPACE_BITS, cpu->phys_bits); return; } } @@ -3698,7 +3701,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) * is the value used by TCG (40). */ if (cpu->phys_bits == 0) { -cpu->phys_bits = TCG_PHYS_ADDR_BITS; +cpu->phys_bits = DEFAULT_PHYS_ADDR_BITS; } } else { /* For 32 bit systems don't use the user set value, but keep diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b086b1528b..fcb7cc8b96 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -280,7 +280,6 @@ #define PG_GLOBAL_MASK (1 << PG_GLOBAL_BIT) #define PG_PSE_PAT_MASK (1 << PG_PSE_PAT_BIT) #define PG_ADDRESS_MASK 0x000ff000LL -#define PG_HI_RSVD_MASK (PG_ADDRESS_MASK & ~PHYS_ADDR_MASK) #define PG_HI_USER_MASK 0x7ff0LL #define PG_PKRU_MASK (15ULL << PG_PKRU_BIT) #define PG_NX_MASK (1ULL << PG_NX_BIT) @@ -1498,15 +1497,19 @@ uint64_t cpu_get_tsc(CPUX86State *env); #define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif -/* XXX: This value should match the one returned by CPUID - * and in exec.c */ +/* + * This value matches the one returned by CPUID when running in KVM mode + * but for TCG as the host might be a different architecture so rely on + * either what the user passed in the cpu property phys-bits or use the + * default value. + */ # if defined(TARGET_X86_64) -# define TCG_PHYS_ADDR_BITS 40 +# define DEFAULT_PHYS_ADDR_BITS 40 # else -# define TCG_PHYS_ADDR_BITS 36 +# define DEFAULT_PHYS_ADDR_BITS 36 # endif -#define PHYS_ADDR_MASK MAKE_64BIT_MASK(0, TCG_PHYS_ADDR_BITS) +#define PHYS_ADDR_MASK(cpu) MAKE_64BIT_MASK(0, cpu->phys_bits) #define cpu_init(cpu_model) cpu_generic_init(TYPE_X86_CPU, cpu_model) diff --git a/target/i386/excp_helper.c b/target/i386/excp_helper.c index cef44495ab..835c4379a9 100644 --- a/target/i386/excp_helper.c +++ b/target/i386/excp_helper.c @@ -173,7 +173,7 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; -uint64_t rsvd_mask = PG_HI_RSVD_MASK; +uint64_t rsvd_mask = (PG_ADDRESS_MASK & ~PHYS_ADDR_MASK(cpu)); uint32_t page_offset; target_ulong vaddr; -- 2.14.1
[Qemu-devel] [PATCH] sockets: Fix test for DragonFly BSD
From f57cdc7ec2d5a5e906fa8b795eeede2d7b66aa56 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Fri, 15 Dec 2017 01:08:10 +0100 Subject: [PATCH] sockets: Fix test for DragonFly BSD DragonFly BSD does not implement AI_V4MAPPED for its getaddrinfo() so probe and discard that flag instead of aborting the test. Test that fails: ERROR:tests/test-char.c:448:char_udp_test_internal: 'chr' should not be NULL Signed-off-by: Antonio Huete Jimenez --- util/qemu-sockets.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index af4f01211a..5a9c55c303 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -43,6 +43,8 @@ # define AI_NUMERICSERV 0 #endif +int useV4Mapped = 1; + static int inet_getport(struct addrinfo *e) { @@ -383,7 +385,6 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, struct addrinfo ai, *res; int rc; Error *err = NULL; -static int useV4Mapped = 1; memset(&ai, 0, sizeof(ai)); @@ -474,7 +475,11 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, /* lookup peer addr */ memset(&ai,0, sizeof(ai)); -ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; +ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; +if (atomic_read(&useV4Mapped)) { +ai.ai_flags |= AI_V4MAPPED; +} + ai.ai_family = inet_ai_family_from_address(sraddr, &err); ai.ai_socktype = SOCK_DGRAM; @@ -493,7 +498,21 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, goto err; } -if ((rc = getaddrinfo(addr, port, &ai, &peer)) != 0) { +/* lookup */ +rc = getaddrinfo(addr, port, &ai, &peer); + +/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but + * then don't implement it in their getaddrinfo(). Detect + * this and retry without the flag since that's preferrable + * to a fatal error + */ +if (rc == EAI_BADFLAGS && +(ai.ai_flags & AI_V4MAPPED)) { +atomic_set(&useV4Mapped, 0); +ai.ai_flags &= ~AI_V4MAPPED; +rc = getaddrinfo(addr, port, &ai, &peer); +} +if (rc != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", addr, port, gai_strerror(rc)); goto err; -- 2.15.0
Re: [Qemu-devel] Timer interrupts for -M raspi2
Hi Andrew, Yeah, that's what I think. I believe I must be overlooking something but I just can't find what. With regards to the ARM Generic timer, I have set the enable bit[0] for CNTP_CTL and also I've set CNTP_TVAL, that's why I think the interrupt is triggered on the real hardware. I'm hoping anywone here can give me a hint on what I might be doing wrong. In any case thanks a lot for your help and patience :-) Best regards, Antonio Huete Andrew Baumann escribió: Hi Antonio, From: Antonio Huete Jiménez [mailto:tuxi...@quantumachine.net] Sent: Wednesday, 16 March 2016 4:24 PM Hi Andrew, I thought the timer that was not implemented was the local timer (located at 0x4034) and that the core timers interrupt control registers starting at 0x4040 were the per-core timers. Oh, sorry, you're right; I replied too quickly. Yes, that should work. Bits 0 and 3 are wired up to what qemu refers to as GTIMER_PHYS and GTIMER_VIRT respectively. (The other two timers aren't currently connected; I can't remember if that's because they weren't modelled by core QEMU when I was implementing the device model, or just because I wasn't sure how to route them and never came back to fix it.) If you are seeing interrupts on real hardware and not on qemu, then it may be because the board performs some additional setup that you are relying on. I'm hardly an expert on ARM, but I would imagine you need to also need to setup the timer's control and count registers (using mcr/mrc) to get it ticking. The write to 0x4040 simply enables the interrupt. Can you please point me to the documentation about this ARM per-core timers? Here's a starting point to some docs (just from a quick search): http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0438c/BGBBIJCB.html Cheers, Andrew Andrew Baumann escribió: > Hi Antonio, > >> From: Antonio Huete Jiménez [mailto:tuxi...@quantumachine.net] >> Sent: Wednesday, 16 March 2016 3:40 PM >> >> Hi, >> >> I am experiencing what I think it's an issue with -M raspi2 and >> interrupts in a baremetal application. >> >> According to this document >> (https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2 >> 836/QA7_rev3.4.pdf), and if I understood it correctly, you can enable timer >> interrupts for core0 by setting bit 0 at 0x4040 and you can trigger them >> by using the ARM Generic >> Timer. >> >> With this procedure I can reliably trigger that timer interrupt in the >> real hardware by setting CNTP_CTL and CNTP_TVAL but on qemu it doesn't >> seem to be triggered. >> >> Can somebody please tell me what I might be doing wrong? > > I don't think you're doing anything wrong; we just don't model this > timer hardware yet (neither Linux nor Windows needs it). If you want > to take a stab at adding it, the relevant hardware emulation is > hw/intc/bcm2836_control.c. > > If you're willing to use different timer sources, then I suggest > looking at the ARM per-core timers. I also have Gregory's emulation > code for the other bcm2835 timers in my private github, and I hope > to submit to upstream qemu after the current freeze, since it is > needed for pi1 Linux support. > > Cheers, > Andrew
[Qemu-devel] Timer interrupts for -M raspi2
Hi, I am experiencing what I think it's an issue with -M raspi2 and interrupts in a baremetal application. According to this document (https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf), and if I understood it correctly, you can enable timer interrupts for core0 by setting bit 0 at 0x4040 and you can trigger them by using the ARM Generic Timer. With this procedure I can reliably trigger that timer interrupt in the real hardware by setting CNTP_CTL and CNTP_TVAL but on qemu it doesn't seem to be triggered. Can somebody please tell me what I might be doing wrong? Let me know if any piece of information is missing. Many thanks, Antonio Huete
Re: [Qemu-devel] Timer interrupts for -M raspi2
Hi Andrew, I thought the timer that was not implemented was the local timer (located at 0x4034) and that the core timers interrupt control registers starting at 0x4040 were the per-core timers. Can you please point me to the documentation about this ARM per-core timers? Thanks, Antonio Huete Andrew Baumann escribió: Hi Antonio, From: Antonio Huete Jiménez [mailto:tuxi...@quantumachine.net] Sent: Wednesday, 16 March 2016 3:40 PM Hi, I am experiencing what I think it's an issue with -M raspi2 and interrupts in a baremetal application. According to this document (https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2 836/QA7_rev3.4.pdf), and if I understood it correctly, you can enable timer interrupts for core0 by setting bit 0 at 0x4040 and you can trigger them by using the ARM Generic Timer. With this procedure I can reliably trigger that timer interrupt in the real hardware by setting CNTP_CTL and CNTP_TVAL but on qemu it doesn't seem to be triggered. Can somebody please tell me what I might be doing wrong? I don't think you're doing anything wrong; we just don't model this timer hardware yet (neither Linux nor Windows needs it). If you want to take a stab at adding it, the relevant hardware emulation is hw/intc/bcm2836_control.c. If you're willing to use different timer sources, then I suggest looking at the ARM per-core timers. I also have Gregory's emulation code for the other bcm2835 timers in my private github, and I hope to submit to upstream qemu after the current freeze, since it is needed for pi1 Linux support. Cheers, Andrew