From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930512; cv=none; d=zoho.com; s=zohoarc; b=lrawC6UbcYb9AxIR+7OFU/Om1my/QC7TsJ4vaLS9d2/ejO3m3rIhZfD9pCO1R+5vsn397Uozy474rZDcFyhq+weSsRluJkNsBccshBSRsefo14XgdTTulZYquGVF1rbGW0OsfcMZYLRKgO/OIYiYr6QClrUw0nmI8H6jmKkNx78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930512; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QVjziJV/GbvmaoW+DHNw8wzHLwg9ajCUZw0RDTVnmHI=; b=TE85rvwEoaySsJHtUqFxXamhI2WT6sB5wYG70jYJW++jZ7vjxVNVpLzAvf51PAY03pVMZQcly+8Pv6H02nk3LkIz/d6a0f/a6Ht1Zmp9vOafXepP+ZIa6eCbhidcAJvqEPhl8oajhKh/ZQEj3XnJ/P8am0+dxA7ba4/th8CnpNE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930512975541.1064299689059; Thu, 24 Oct 2019 08:21:52 -0700 (PDT) Received: from localhost ([::1]:45286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNevv-0004E0-Lk for importer@patchew.org; Thu, 24 Oct 2019 11:21:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34606) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdig-0006t7-Sy for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdib-0007Zy-Hp for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:38049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdib-0007Yq-2M for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:01 -0400 Received: by mail-wm1-x335.google.com with SMTP id 3so2739415wmi.3 for ; Thu, 24 Oct 2019 07:03:59 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QVjziJV/GbvmaoW+DHNw8wzHLwg9ajCUZw0RDTVnmHI=; b=PaAWcHzWrL/DTwDYUsib8LN+QztuGuY5I383DlPJsU1zVkdJZTn5bI47veQoEWeviA FYxScYSZTk/gxFSANkhe+wMAq9FEeYdIKj9p70SDlnUU3ui42SL5vo7EwihnTJqJVG8d V5U8dxpRRk20J/LfGKbYlXrXVXFegPaVjy3TEyIM7RQXkVClmeLmJD7HcheHi/xtZKC2 Cf+KbvKU9N39RTjR5mLrn3lyYuWmzYc8dMHgDtJRGmL/OMpATcAYFSRH65uOrJ0cEJPw 6gcwFayWtCWr6Y8qNt1yERn7KMzaqWxsP8C2lj0rBHNlp/Yh1USChWowuUPTXjmINfQ2 GLvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QVjziJV/GbvmaoW+DHNw8wzHLwg9ajCUZw0RDTVnmHI=; b=Szy2pvAA2ILRG0uhbhv2RHHPttZsJIdE3PARoXaOpl3cSgteykN21VsOKKz8IEHrru +WylRPJeq7jKw/yCaFY9We/hskDoo6IPyvN+E8hiJ/bB4U9zpQ70ad7tOw+87PAVJLJm f2W760eBM+o/SyaQZiMzS8KsD3J0lZjOGWn+KiUXhJFIEFGK+t1eTAk8itN1596YCjdl e+J6p85vSqp6b88WuDSUe7lunDwcEfNqp7MmaBwqvnrETmKwoObQ/RAn00xfwC1YAhli xM528G4qqqrStdpGxXoLGoXpIPRD/hhtQ+VHzn+fJ0pLmWnVifPQIIdqB+rHmXTCiwzq Ctdg== X-Gm-Message-State: APjAAAWuTsqha8QZpmr55KN3uWBCKVDXc9/7S/TCkOutjacFuFJuuQpL PIBA6QzKxcb9U4wwdB3DViAAS17U X-Google-Smtp-Source: APXvYqyGMxkCzR4vc0Ce77FAvO57ZOR5L+mbXrzN2Rg/Fv90ESpNuBOKVawz8GfiWXYz53LWla0p1Q== X-Received: by 2002:a1c:e08a:: with SMTP id x132mr5205677wmg.146.1571925838509; Thu, 24 Oct 2019 07:03:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/39] target/i386: log MCE guest and host addresses Date: Thu, 24 Oct 2019 16:03:17 +0200 Message-Id: <1571925835-31930-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mario Smarduch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mario Smarduch Patch logs MCE AO, AR messages injected to guest or taken by QEMU itself. We print the QEMU address for guest MCEs, helps on hypervisors that have another source of MCE logging like mce log, and when they go missing. For example we found these QEMU logs: September 26th 2019, 17:36:02.309 Droplet-153258224: Guest MCE Memor= y Error at qemu addr 0x7f8ce14f5000 and guest 3d6f5000 addr of type BUS_MCE= ERR_AR injected qemu-system-x86_64 amsN ams3nodeNNNN September 27th 2019, 06:25:03.234 Droplet-153258224: Guest MCE Memor= y Error at qemu addr 0x7f8ce14f5000 and guest 3d6f5000 addr of type BUS_MCE= ERR_AR injected qemu-system-x86_64 amsN ams3nodeNNNN The first log had a corresponding mce log entry, the second didnt (logging thresholds) we can infer from second entry same PA and mce type. Signed-off-by: Mario Smarduch Message-Id: <20191009164459.8209-3-msmarduch@digitalocean.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 8c73438..0e3da99 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -592,9 +592,9 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, i= nt code) (MCM_ADDR_PHYS << 6) | 0xc, flags); } =20 -static void hardware_memory_error(void) +static void hardware_memory_error(void *host_addr) { - fprintf(stderr, "Hardware memory error!\n"); + error_report("QEMU got Hardware memory error at addr %p", host_addr); exit(1); } =20 @@ -618,15 +618,34 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { kvm_hwpoison_page_add(ram_addr); kvm_mce_inject(cpu, paddr, code); + + /* + * Use different logging severity based on error type. + * If there is additional MCE reporting on the hypervisor, QEM= U VA + * could be another source to identify the PA and MCE details. + */ + if (code =3D=3D BUS_MCEERR_AR) { + error_report("Guest MCE Memory Error at QEMU addr %p and " + "GUEST addr 0x%" HWADDR_PRIx " of type %s injected", + addr, paddr, "BUS_MCEERR_AR"); + } else { + warn_report("Guest MCE Memory Error at QEMU addr %p and " + "GUEST addr 0x%" HWADDR_PRIx " of type %s injected", + addr, paddr, "BUS_MCEERR_AO"); + } + return; } =20 - fprintf(stderr, "Hardware memory error for memory used by " - "QEMU itself instead of guest system!\n"); + if (code =3D=3D BUS_MCEERR_AO) { + warn_report("Hardware memory error at addr %p of type %s " + "for memory used by QEMU itself instead of guest system!", + addr, "BUS_MCEERR_AO"); + } } =20 if (code =3D=3D BUS_MCEERR_AR) { - hardware_memory_error(); + hardware_memory_error(addr); } =20 /* Hope we are lucky for AO MCE */ --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929687; cv=none; d=zoho.com; s=zohoarc; b=PieZq++XHShkm8+eX+lF5XKUzYbMka4aosewGHjFUNbiZ5/YXnReFiAU2qqWCLxYmOE9augtmFlDyzwwfx+zwgNQ/+Hrsn8LACooOrdhhD8oTJN0jeoTOixLYw6JSUCQL5yBPzpDqEAnYew917f6/DBV1Hp1EZ0Sm2HnpaYNUCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929687; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=iGmswL4U/5XW7ql7Ew8zQ48E5AkJVaBYfQW9kZ657mI=; b=AlNaVXWNTl679MX7CGXFaQDPa3+F3RdHk6zvbSoZC3V4865UUsmzf0N0IutXCablhVEKnQckjmMYpbNBCukrvRqIHZMzglVDA0frEKVlUHeHIWtMsAUSomFbFa+eRex6pvbAVXj8Ua+G8ZZTVAx7WamuLGbJfBlGaYNwTLr5/pI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571929687382558.7284808179019; Thu, 24 Oct 2019 08:08:07 -0700 (PDT) Received: from localhost ([::1]:45151 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeic-0001Qq-4w for importer@patchew.org; Thu, 24 Oct 2019 11:08:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34607) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdig-0006t8-St for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdib-0007a3-Hs for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdib-0007ZZ-3O for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:01 -0400 Received: by mail-wm1-x343.google.com with SMTP id w9so1561263wmm.5 for ; Thu, 24 Oct 2019 07:04:01 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iGmswL4U/5XW7ql7Ew8zQ48E5AkJVaBYfQW9kZ657mI=; b=ps38OElF2RwitS8r3osFXr8symM/iIehe0wXdlIb3ctYk1BNZrHA0bR0eMFzp5+hPP RxPs0TNWiIQFoIaf7dRLZpfTD6CFmtJgxhcaj3lsGsLrrU4XcPgsg/Hs39YPoUpRfH8R c741xxkW87CXl5sVmhSUtXUIqVwzVp+WzsIbMqeqZowSv8+/NMg82kz7l36hUnea5mGL iJU9K0ahgTI0hgpivTpwqVjAGZKNk0PuGFMTbLwk8gw8NquQJRCQ7OJ9Rc6z9GhE7RGk rUA8gqt/4vS0NdPqJxXIZuNe1tKCFLEj1QUbs37eFnuICqT0VLE8LyuWskrxt7FjWtls Hh6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=iGmswL4U/5XW7ql7Ew8zQ48E5AkJVaBYfQW9kZ657mI=; b=DzRkVQ5rADWzRuSv974YPbYlZrWu2y6INKqf+nJsyHlpW+HS6tDh3e5nsL4qxUV4lE Dni8PSs1n880wxhpGLdA6PrPUrDYJIyPlts3bHSaj2OpTMGbhdFNSAhep9APuk6gzJX8 zOrKoghR5mhq5UM4XB9wHpCAQJjXEi0zpXtMd4sVeLAgZ+66Y6Np8Qrq7HpBqM4597C7 sIXkbuzJ3E5Z596e201PR/xWLOxENojZUNxp4O8mNFWPu1WF86LD2nIHPmPLpZad4H4D WyYKV7ZmzZ1E2ShKdpbrUSDLZMW9YTZgH51h1diJafahqJ1AAgohukMGEybgsIEe7VA1 AsJA== X-Gm-Message-State: APjAAAVFjyGFOqQJ7IT8rCuPKtzCStcaQqjheiXbDgEChkyUEkt0iHuC s/PPQqAMwKX7tQlpnfU9k/qYN8US X-Google-Smtp-Source: APXvYqxV6x/LUk/FGWOTOI4l7+8LG8EaHqdcHV1pkWRoOOYvdchHy1F001MLq6RepbdnpeI92C0Ptg== X-Received: by 2002:a1c:e404:: with SMTP id b4mr5555773wmh.90.1571925839703; Thu, 24 Oct 2019 07:03:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/39] mc146818rtc: fix timer interrupt reinjection Date: Thu, 24 Oct 2019 16:03:18 +0200 Message-Id: <1571925835-31930-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcelo Tosatti Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Marcelo Tosatti commit 369b41359af46bded5799c9ef8be2b641d92e043 broke timer interrupt reinjection when there is no period change by the guest. In that case, old_period is 0, which ends up zeroing irq_coalesced (counter of reinjected interrupts). The consequence is Windows 7 is unable to synchronize time via NTP. Easily reproducible by playing a fullscreen video with cirrus and VNC. Fix by not updating s->irq_coalesced when old_period is 0. V2: reorganize code (Paolo Bonzini) Signed-off-by: Marcelo Tosatti Message-Id: <20191010123008.GA19158@amt.cnet> Signed-off-by: Paolo Bonzini --- hw/timer/mc146818rtc.c | 53 +++++++++++++++++++++++++---------------------= ---- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 6cb3787..0e7cf97 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -203,24 +203,28 @@ periodic_timer_update(RTCState *s, int64_t current_ti= me, uint32_t old_period) =20 period =3D rtc_periodic_clock_ticks(s); =20 - if (period) { - /* compute 32 khz clock */ - cur_clock =3D - muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND); + if (!period) { + s->irq_coalesced =3D 0; + timer_del(s->periodic_timer); + return; + } =20 - /* - * if the periodic timer's update is due to period re-configuration, - * we should count the clock since last interrupt. - */ - if (old_period) { - int64_t last_periodic_clock, next_periodic_clock; - - next_periodic_clock =3D muldiv64(s->next_periodic_time, - RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND= ); - last_periodic_clock =3D next_periodic_clock - old_period; - lost_clock =3D cur_clock - last_periodic_clock; - assert(lost_clock >=3D 0); - } + /* compute 32 khz clock */ + cur_clock =3D + muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND); + + /* + * if the periodic timer's update is due to period re-configuration, + * we should count the clock since last interrupt. + */ + if (old_period) { + int64_t last_periodic_clock, next_periodic_clock; + + next_periodic_clock =3D muldiv64(s->next_periodic_time, + RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND); + last_periodic_clock =3D next_periodic_clock - old_period; + lost_clock =3D cur_clock - last_periodic_clock; + assert(lost_clock >=3D 0); =20 /* * s->irq_coalesced can change for two reasons: @@ -251,22 +255,19 @@ periodic_timer_update(RTCState *s, int64_t current_ti= me, uint32_t old_period) rtc_coalesced_timer_update(s); } } else { - /* + /* * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW * is not used, we should make the time progress anyway. */ lost_clock =3D MIN(lost_clock, period); } + } =20 - assert(lost_clock >=3D 0 && lost_clock <=3D period); + assert(lost_clock >=3D 0 && lost_clock <=3D period); =20 - next_irq_clock =3D cur_clock + period - lost_clock; - s->next_periodic_time =3D periodic_clock_to_ns(next_irq_clock) + 1; - timer_mod(s->periodic_timer, s->next_periodic_time); - } else { - s->irq_coalesced =3D 0; - timer_del(s->periodic_timer); - } + next_irq_clock =3D cur_clock + period - lost_clock; + s->next_periodic_time =3D periodic_clock_to_ns(next_irq_clock) + 1; + timer_mod(s->periodic_timer, s->next_periodic_time); } =20 static void rtc_periodic_timer(void *opaque) --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927312; cv=none; d=zoho.com; s=zohoarc; b=Kr+hYMpGRGgrvGLGXZRuslxx/sQbh4XTuu5bWJsbjTP/72nkOQpYe2fgaABM8G+ZODl7ujse2ASGfeSWDUuAupx8DG+ZNMImNf83CQQhu4dsU5AR5+YBb5RYuwGrTeE3qu+9T72dBnmAkNJMdKMuAI/vTlK671jH8QCrbq3dY1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927312; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fuQszgdPGBPwvusB1Bd3Ai26mEtUdVTfTTnv1HWpc9k=; b=WyYIIUajWYT4o5rR+fJ8WRPpCB0tfE91XxTUY8xJ9T6rkBiJfGcXWctIAHpw5tHmn7EBelVD5g5RfJuH3hBpVu5s4ImAC4qv/z05rw01eI7SlyXEq6atTkBU+VCGKBBRsoHyIWM2xXcdQHbGc6gaV+Ki7AL9gRbrY8O6sWJVJOs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927312208573.5310567563749; Thu, 24 Oct 2019 07:28:32 -0700 (PDT) Received: from localhost ([::1]:44214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNe6I-00044Q-LZ for importer@patchew.org; Thu, 24 Oct 2019 10:28:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34590) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdif-0006pQ-TJ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdic-0007aV-Cj for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:04 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdic-0007Zt-5T for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:02 -0400 Received: by mail-wr1-x432.google.com with SMTP id a11so10151735wra.6 for ; Thu, 24 Oct 2019 07:04:02 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.03.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fuQszgdPGBPwvusB1Bd3Ai26mEtUdVTfTTnv1HWpc9k=; b=fk89SAkAlx/Nn/JW1Za5RwIaD5V7z2cnkGECtpxrIQJaCIrQj+knp6U+tJVdYroGYn jWTcnOxv8pBrpV8M0nTqLO6nrMf1p9U6oYLfI1aC5j4SQCtsdBeMBcSH7JNWaNO/EHKl kP83FpPfv+geS8yPLQQ/uwGFkmCLio/QowGCx7XeZr8WUlMKDFsnfA9n7oQbIUBurtQI sW6ys+tTSVTCgpDhzvWoT9atn3sDNoaTK3vcyH885GjFDNN8sm9p1gR4BMxY2ditH07A jQIrchnHQnATyyyaUjm8mPGtcsFNM/e8izVK5DiSK9G5mP1EzI2gefe8P1DiuMU9+9rU E3YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=fuQszgdPGBPwvusB1Bd3Ai26mEtUdVTfTTnv1HWpc9k=; b=jKCp+zCZa30Uk5R3B6LlaPaT/zV9jXV6IhHS3zS6CBWHeXQ99RCtAmNDW6OZD6s1jp 4M8+hFt0Lk3+a+AFpGHk9TNsRz0icaiHqbkPO3eeVjPNbxkM3CZ/WGNajSiOn9UVkNwE 2sk5/J/F1eZJdvvW3eRpzO3F4BQAiqIw9lCTrRLovR9+BwPRyT9AGJERpeV/ZBoEKn1z 9TlZvLQyXUXoqydAhlqqjLgINTOh6T4xNrlawd8cDgZXas+JRKU20EegQn8TP+pGh0Nj yvuLQyyDGiZDvqi8RasJ+RGjqStHtajx76tR4OupsoGCV4CwBGURBArTl5WZ0jSqpeyi tbvQ== X-Gm-Message-State: APjAAAUjTaZy02VyPLom5lKidEHnAQqKtXMHGDMdidaPgJSbPTUc+ErD UGWLJYEGB+cda3aweBDI9cYFEtNt X-Google-Smtp-Source: APXvYqzRkWulffXzHasD8OjUDZJBDhorCjTD/nzYF1DSfQKnkBKYvbSDUj/bMc7A2ufMMAk19ycEbQ== X-Received: by 2002:a5d:674f:: with SMTP id l15mr4388528wrw.80.1571925840725; Thu, 24 Oct 2019 07:04:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/39] Updated Bulgarian translation (19) - 4.1.0 Date: Thu, 24 Oct 2019 16:03:19 +0200 Message-Id: <1571925835-31930-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Shopov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Shopov Signed-off-by: Alexander Shopov Message-Id: <20191019120534.27479-2-ash@kambanaria.org> Signed-off-by: Paolo Bonzini --- po/bg.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/po/bg.po b/po/bg.po index 3d8c353..98c57e5 100644 --- a/po/bg.po +++ b/po/bg.po @@ -1,14 +1,14 @@ # Bulgarian translation of qemu po-file. -# Copyright (C) 2016 Alexander Shopov +# Copyright (C) 2016, 2019 Alexander Shopov # This file is distributed under the same license as the qemu package. -# Alexander Shopov , 2016. +# Alexander Shopov , 2016, 2019. # msgid "" msgstr "" -"Project-Id-Version: QEMU 2.6.50\n" +"Project-Id-Version: QEMU 4.1.0\n" "Report-Msgid-Bugs-To: qemu-devel@nongnu.org\n" "POT-Creation-Date: 2018-07-18 07:56+0200\n" -"PO-Revision-Date: 2016-06-09 15:54+0300\n" +"PO-Revision-Date: 2019-10-19 13:14+0200\n" "Last-Translator: Alexander Shopov \n" "Language-Team: Bulgarian \n" "Language: bg\n" @@ -66,7 +66,7 @@ msgid "Detach Tab" msgstr "=D0=9A=D1=8A=D0=BC =D1=81=D0=B0=D0=BC=D0=BE=D1=81=D1=82=D0=BE=D1= =8F=D1=82=D0=B5=D0=BB=D0=B5=D0=BD =D0=BF=D0=BE=D0=B4=D0=BF=D1=80=D0=BE=D0= =B7=D0=BE=D1=80=D0=B5=D1=86" =20 msgid "Show Menubar" -msgstr "" +msgstr "=D0=9B=D0=B5=D0=BD=D1=82=D0=B0 =D0=B7=D0=B0 =D0=BC=D0=B5=D0=BD=D1= =8E=D1=82=D0=BE" =20 msgid "_Machine" msgstr "_=D0=9C=D0=B0=D1=88=D0=B8=D0=BD=D0=B0" --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571926003; cv=none; d=zoho.com; s=zohoarc; b=T+4F8dy0juPFw53Zo/aYA9fFwQAcK8kFGwmGgsGn8yE13Z4Ck3m5caT+AeJ6AW8+QOadLOeHLmGNU8ZGOTnNDIIaTArBtJqHZJY825Gqfup/boyC3q2tn6jOH7U+50x827Rz+jCGaPbMU0pzfAV01TWXtQwmTboqwixa3r4qT4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571926003; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=klIHsHZRArDFTcQXKJkBiIBV52Qlwr6+QqqMGTKzp4Y=; b=FtARfu1Pm2eOkVeaapSVCO2WQoGiDeO23vPNYEsGyr9NcA9UDHratGg/FDF8Ebu2P46z9PhIHM6gSJ8oPCzTDmkXOFGu56rg9+PxHLm+ovHY7zq+2kIeFoSrzHFrJy0LISI3nxT/gmVjLLXq0Wpvyni/uXahGuB2zCqr2Wo9gI4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571926003974833.382968975701; Thu, 24 Oct 2019 07:06:43 -0700 (PDT) Received: from localhost ([::1]:43630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdlC-0002F1-59 for importer@patchew.org; Thu, 24 Oct 2019 10:06:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdih-0006vR-DI for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdif-0007cr-Sv for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:07 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:39153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdid-0007ag-VY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:05 -0400 Received: by mail-wm1-x334.google.com with SMTP id r141so2730756wme.4 for ; Thu, 24 Oct 2019 07:04:03 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=klIHsHZRArDFTcQXKJkBiIBV52Qlwr6+QqqMGTKzp4Y=; b=MMHLOjgl1bnUBY6IdFLx285S7DNwKFsOmKFUhbFwpwfHtuIGPnwREJjhs8s9HTTy/n ql7iBfG+OFMnetnBsLrSI84jdSAnNQ9mNLiodWzgOE2ijTb5o5UJo5qDXCrWplVGG1Iq 8BgLwLwyCItaLKzAP0SqsHK181uPRsV9eEeY0ilUTzZV/gHHqVG77oNEqTFh3/FynE+W hzHjn1AN6DYdJQ+yKlo3Fp4Bsw3WvFdDCBddjuzzDqlZcOt97h0GWnI0qq+kWTEt7LW/ ZPbXCVBv/+aRGAS+sEXElbTxlUsYv9h5I4aHOXQIW6G68I9MH+sIP6AGdivNCm+Cg7Le ylOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=klIHsHZRArDFTcQXKJkBiIBV52Qlwr6+QqqMGTKzp4Y=; b=le9UAQRbHPMFg6XOhz4m48mwdFsrR1ndj/U9wvz0ShTKva+35NWGqzrRc3U77npm9F 6qdarn/KqccgQRtUHlSul8z3yeF1IuPQ8khnSZa6T9gkFlf1k28tovO980T6hnVHjBXe N+WhfSWzhZIFkPxFn7QuoVuZsNsrs4jzwJRumaK0RYreKrAIP3mJJZfwY7oUsjOOrX9l fGE1+lKbOBqmFUIh5Y7/7XjUL/A5fMwZOMOL5PYggCv5CQAQCn298jUwnNAgX3Pidwi+ g+NGe+R6DRdgfdQwIMm5s4SzlnUYN9CZxcIF8n03Vfqv0JW94VbYcgFO9gitqliIDqd2 7dCw== X-Gm-Message-State: APjAAAVhSO/ekQ6i1igpZcvvxXUPPiU91mF6ItZrKt7U/HrcNCvE9O2c bOpQZBE1rJ/iUFvEicvWyckxw+FM X-Google-Smtp-Source: APXvYqzECZXcbGB7oBpbaaliiXU+gqvirWlpGsd4yHMYg5ElFnnphMNWamuXzaY9vxNqJ+EgrqUoPg== X-Received: by 2002:a1c:a556:: with SMTP id o83mr5491549wme.0.1571925841889; Thu, 24 Oct 2019 07:04:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/39] i386/kvm: add NoNonArchitecturalCoreSharing Hyper-V enlightenment Date: Thu, 24 Oct 2019 16:03:20 +0200 Message-Id: <1571925835-31930-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Hyper-V TLFS specifies this enlightenment as: "NoNonArchitecturalCoreSharing - Indicates that a virtual processor will ne= ver share a physical core with another virtual processor, except for virtual processors that are reported as sibling SMT threads. This can be used as an optimization to avoid the performance overhead of STIBP". However, STIBP is not the only implication. It was found that Hyper-V on KVM doesn't pass MD_CLEAR bit to its guests if it doesn't see NoNonArchitecturalCoreSharing bit. KVM reports NoNonArchitecturalCoreSharing in KVM_GET_SUPPORTED_HV_CPUID to indicate that SMT on the host is impossible (not supported of forcefully disabled). Implement NoNonArchitecturalCoreSharing support in QEMU as tristate: 'off' - the feature is disabled (default) 'on' - the feature is enabled. This is only safe if vCPUS are properly pinned and correct topology is exposed. As CPU pinning is done outside of QEMU the enablement decision will be made on a higher level. 'auto' - copy KVM setting. As during live migration SMT settings on the source and destination host may differ this requires us to add a migration blocker. Signed-off-by: Vitaly Kuznetsov Message-Id: <20191018163908.10246-1-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 13 +++++++++++++ target/i386/cpu.c | 2 ++ target/i386/cpu.h | 2 ++ target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 26 ++++++++++++++++++++++++++ 5 files changed, 44 insertions(+) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 8fdf25c..6518b71 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -184,6 +184,19 @@ enabled. =20 Requires: hv-vpindex, hv-synic, hv-time, hv-stimer =20 +3.17. hv-no-nonarch-coresharing=3Don/off/auto +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This enlightenment tells guest OS that virtual processors will never share= a +physical core unless they are reported as sibling SMT threads. This inform= ation +is required by Windows and Hyper-V guests to properly mitigate SMT related= CPU +vulnerabilities. +When the option is set to 'auto' QEMU will enable the feature only when KVM +reports that non-architectural coresharing is impossible, this means that +hyper-threading is not supported or completely disabled on the host. This +setting also prevents migration as SMT settings on the destination may dif= fer. +When the option is set to 'on' QEMU will always enable the feature, regard= less +of host setup. To keep guests secure, this can only be used in conjunction= with +exposing correct vCPU topology and vCPU pinning. =20 4. Development features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 47200b4..6c87c99 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6174,6 +6174,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_IPI, 0), DEFINE_PROP_BIT64("hv-stimer-direct", X86CPU, hyperv_features, HYPERV_FEAT_STIMER_DIRECT, 0), + DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, + hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index cedb5bc..c50a9c7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -24,6 +24,7 @@ #include "cpu-qom.h" #include "hyperv-proto.h" #include "exec/cpu-defs.h" +#include "qapi/qapi-types-common.h" =20 /* The x86 has a strong memory model with some store-after-load re-orderin= g */ #define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) @@ -1614,6 +1615,7 @@ struct X86CPU { bool hyperv_synic_kvm_only; uint64_t hyperv_features; bool hyperv_passthrough; + OnOffAuto hyperv_no_nonarch_cs; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index cffac10..056a305 100644 --- a/target/i386/hyperv-proto.h +++ b/target/i386/hyperv-proto.h @@ -63,6 +63,7 @@ #define HV_CLUSTER_IPI_RECOMMENDED (1u << 10) #define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11) #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) +#define HV_NO_NONARCH_CORESHARING (1u << 18) =20 /* * Basic virtualized MSRs diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 0e3da99..49a3011 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1227,6 +1227,16 @@ static int hyperv_handle_properties(CPUState *cs, } } =20 + if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { + env->features[FEAT_HV_RECOMM_EAX] |=3D HV_NO_NONARCH_CORESHARING; + } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { + c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); + if (c) { + env->features[FEAT_HV_RECOMM_EAX] |=3D + c->eax & HV_NO_NONARCH_CORESHARING; + } + } + /* Features */ r =3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RELAXED); r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VAPIC); @@ -1340,6 +1350,7 @@ free: } =20 static Error *hv_passthrough_mig_blocker; +static Error *hv_no_nonarch_cs_mig_blocker; =20 static int hyperv_init_vcpu(X86CPU *cpu) { @@ -1359,6 +1370,21 @@ static int hyperv_init_vcpu(X86CPU *cpu) } } =20 + if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO && + hv_no_nonarch_cs_mig_blocker =3D=3D NULL) { + error_setg(&hv_no_nonarch_cs_mig_blocker, + "'hv-no-nonarch-coresharing=3Dauto' CPU flag prevents m= igration" + " use explicit 'hv-no-nonarch-coresharing=3Don' instead= (but" + " make sure SMT is disabled and/or that vCPUs are prope= rly" + " pinned)"); + ret =3D migrate_add_blocker(hv_no_nonarch_cs_mig_blocker, &local_e= rr); + if (local_err) { + error_report_err(local_err); + error_free(hv_no_nonarch_cs_mig_blocker); + return ret; + } + } + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VPINDEX) && !hv_vpindex_setta= ble) { /* * the kernel doesn't support setting vp_index; assert that its va= lue --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927558; cv=none; d=zoho.com; s=zohoarc; b=Yo4lyFykinxRoUGHw3+N4Q8TuXYCPBfBzGmVNzsLmRpDDC3goAPPaPQsSyYl6/wuTbH17GkHSurhQ8lAzh7QMz7WCU7s1w+wki68SfAkvfQ1dzEOwcXJx6ulfL3+vYiYCplYQUh62ga00qJSKBBP9UrzQGQWvxHvP4prR4nKhTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927558; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=eDqUf3tUY4rbcJXSYYsBnrRp/4Ymro7vBsHB22cxah36VA5DtBkUOoCE6OjBTufQBu1AzpPfqGakhFbeP3wnwCOZATstKMwCa+2YOKGAA937drm5XwgbHVzrY04cAvSKSeCOnq5cxK/0Tgx4uo2ZhnqQQjd0nWsoKX4bevTjOAA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927558086997.8060588952402; Thu, 24 Oct 2019 07:32:38 -0700 (PDT) Received: from localhost ([::1]:44296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeAC-0003Dp-4y for importer@patchew.org; Thu, 24 Oct 2019 10:32:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34631) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdih-0006x8-RV for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdig-0007d5-JT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:07 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdif-0007c4-Ou for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: by mail-wm1-x343.google.com with SMTP id q70so3010998wme.1 for ; Thu, 24 Oct 2019 07:04:04 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=r5qECsBzMoHnH9oYTdqnwSkwxzMAcjqDHgOrOENov38N4SKCao4pyClT42QpKYifIx SZIUAJw3EL+zNKVP9N9KG7cS79k/tGMej1nPTKIQYeGXMNQG8wMobEQbhXcMYqoliLRP 6oCVCrSaVmUoUECfmTCHroDpy/+wvYUGKAwnkzxz3YpgPePlTv/RRxJWLWfVTe/KFkgr /AVxYOc6QbrO22odbMy/JkKZfWx5B9upbvVf7ma4WyH5OuI5t06BtKr1gjRm4xEeQVIb 32Jdm7a52ejFoo7VJq2JtXg14/GHXZw6kzu2+ijHfHrY/1sHc9eHSSVYm6oJ8MSoRL8g WrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=QNp+1/qgS9Yc+3xUHDLxH18LSBUdiLgN0/5gfSuuPKJgdUJGe9WkbxRJbCDd4hTpzC p6PVbYpOeIYdH3oTrzPH3vDgMidpcjBtKlQK9bTcZoQL1RbqzC2W23+GgZcd/WC6+6cN V6y/AWA/o5ZMad6at6Eo9miItQhZmPngWg6Gaut2FhxGjsHfHkJ4NEHI1sih77/0r53e IPZhUqMUk/O7K/4RavfJieNLWATP5P7nVDkAsgj+Q9yK2RvMXwfsiRC+/upIjcpsd+PV uoif9QilS3lSnRr8grSQ3m4dl5fbWLX9AU1VxnqP2hO0f5jjqFtTAwwsXZLhjnyPWahy 93Kg== X-Gm-Message-State: APjAAAXF8sMU4kfS6rf4Dnm9Ll+g6g/+jaXcCE6AYCild+sJ4xXDx93A esNqfDul6UBvoTGJQMnPXYgVgAs8 X-Google-Smtp-Source: APXvYqx06gt8bV4kHJTdwiiTMWl8QalRrQ3caQB2z6aONCWr0QBxGt5XsfAj8EXyKTgjO1/8MqY9ag== X-Received: by 2002:a1c:7913:: with SMTP id l19mr5391774wme.26.1571925843125; Thu, 24 Oct 2019 07:04:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/39] Do not use %m in common code to print error messages Date: Thu, 24 Oct 2019 16:03:21 +0200 Message-Id: <1571925835-31930-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The %m format specifier is an extension from glibc - and when compiling QEMU for NetBSD, the compiler correctly complains, e.g.: /home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c: In function 'sigfd_handle= r': /home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c:64:13: warning: %m is only allowed in syslog(3) like functions [-Wformat=3D] printf("read from sigfd returned %zd: %m\n", len); ^ Let's use g_strerror() here instead, which is an easy-to-use wrapper around the thread-safe strerror_r() function. While we're at it, also convert the "printf()" in main-loop.c into the preferred "error_report()". Signed-off-by: Thomas Huth Message-Id: <20191018130716.25438-1-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/tmp421.c | 4 ++-- util/main-loop.c | 3 ++- util/systemd.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c index 9f04470..c0bc150 100644 --- a/hw/misc/tmp421.c +++ b/hw/misc/tmp421.c @@ -120,7 +120,7 @@ static void tmp421_get_temperature(Object *obj, Visitor= *v, const char *name, int tempid; =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %m", name); + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); return; } =20 @@ -160,7 +160,7 @@ static void tmp421_set_temperature(Object *obj, Visitor= *v, const char *name, } =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %m", name); + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); return; } =20 diff --git a/util/main-loop.c b/util/main-loop.c index e3eaa55..eda63fe 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -61,7 +61,8 @@ static void sigfd_handler(void *opaque) } =20 if (len !=3D sizeof(info)) { - printf("read from sigfd returned %zd: %m\n", len); + error_report("read from sigfd returned %zd: %s", len, + g_strerror(errno)); return; } =20 diff --git a/util/systemd.c b/util/systemd.c index d22e86c..1dd0367 100644 --- a/util/systemd.c +++ b/util/systemd.c @@ -60,8 +60,8 @@ unsigned int check_socket_activation(void) * and we should exit. */ error_report("Socket activation failed: " - "invalid file descriptor fd =3D %d: %m", - fd); + "invalid file descriptor fd =3D %d: %s", + fd, g_strerror(errno)); exit(EXIT_FAILURE); } } --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927111; cv=none; d=zoho.com; s=zohoarc; b=FbkKjJxOdoWsCDLiu1XD3frq8a0np6kDr65ihXwRuV/Mq3Lt6h7pBPs9WNxZ+hqTRIFi9SCdLJPFaYVvHK9iDWZRRhMD6MLyI+bhI0USMg4szJM6xxCk6szh10fmgXX3lRHo30GUfd0QYA5YT4OzzZcES6vM1eVlYGuvR949ioY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927111; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gC+nKqV0M8tEfDmWGeiuGoh13N0jWlVmQT3b97dNgSY=; b=AfBgkKXwuaPXYZBOhe+41mIO9ECOO4BLaenjP0r5+jzNGjaael/HCVqGvL/Sfqh2iTbcS7ZGjKSZeeTwnSFOA1fYts3P3mvaayq7o0PcJ1KWonM2+p5/TqKZdrpaQgZ4kG715gbS/7r1Oq2Bagdvi80AyG736etRn4GRio2J4Kw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927111773276.08998018439286; Thu, 24 Oct 2019 07:25:11 -0700 (PDT) Received: from localhost ([::1]:44102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNe33-0004JR-Ve for importer@patchew.org; Thu, 24 Oct 2019 10:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34635) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdih-0006xK-TQ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdig-0007dT-Su for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:07 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:45364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdig-0007cV-IT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: by mail-wr1-x435.google.com with SMTP id q13so21264273wrs.12 for ; Thu, 24 Oct 2019 07:04:06 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=gC+nKqV0M8tEfDmWGeiuGoh13N0jWlVmQT3b97dNgSY=; b=t19Oi9uOmscQZSWZuKOaqFY8j+svlpPXzfbq8HbUlwn17b+uFFJoDuVJLDykV4uFoa PGgvffsTlML17kn4vM6C/Kp3CEh84nP1F2N8xM5DbKmfYMuulZHQKhcxsyT8qzglp6wp hHKWQKqFvxkxwsRndJEzIEo56vZID027gIUbPyy/7SE0/mF6tFH/CyU/g35DgW+aMkST b44jQxyiu2fCSUA6fbytMUNC4DSI0qnx4iopVYGxRvI3ssDelmwl4pA+o3YA/maSwx74 W51Qt876s+FZt5tGDD4AVJApl2qc+l21PBC9dZ/DjS7640ESD5D8lYLh639HuG606zG6 HLPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=gC+nKqV0M8tEfDmWGeiuGoh13N0jWlVmQT3b97dNgSY=; b=WwCQ4s1wjmAX5Gg/gP7WPM1zMP/FFN0rP/YwM74yDRmf9rrDQcYv+Cgg1pHo4bZbLO /yfRt8LV6rHM9Zk44bJLGj7rHc282N3zlM1RjAbvBzNHdfUy8v/R/b+EMa1rsceNWYSZ r8n145AxYUQ2YiTbriPeQq7YWz7MKc9FhbzZ9boUWSt/AUAlsfSbMrktXXMtpzERKuBk fG0ffILK+EaqQmoiZpkYQ+M2YDd5312fDKLLIiqomeg5wQI8VKrZFXYK/ZnMM//cX/89 Xo4ClDmXMtIbGwEA1DlZ+NpmBbUoWdl1eVvrHV1ezM9VK+4E40YfXbLcFRjLF0eMweAt UmXQ== X-Gm-Message-State: APjAAAW5B7aZDjFfOrTbF9hYvS7KkKVcmVvSs3FvUDIPgZdpWnJqf4JG NuyeLRMX/XU1mSrybmZSwC0ejLa6 X-Google-Smtp-Source: APXvYqwnbunzsnWDEn1KcRz9DxmLsbv9rM46Emat3xNHh41RTQVvKD6ORZWsZgMnx2xwjryLR0z5Eg== X-Received: by 2002:adf:ecc7:: with SMTP id s7mr4016548wro.305.1571925844195; Thu, 24 Oct 2019 07:04:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/39] memory-device: simplify Makefile.objs conditions Date: Thu, 24 Oct 2019 16:03:22 +0200 Message-Id: <1571925835-31930-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" hw/mem/ is only included if CONFIG_MEM_DEVICE is true, so we need not specify the condition again in hw/mem/Makefile.objs. Signed-off-by: Paolo Bonzini --- hw/mem/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/Makefile.objs b/hw/mem/Makefile.objs index 3e2f7c5..56345be 100644 --- a/hw/mem/Makefile.objs +++ b/hw/mem/Makefile.objs @@ -1,3 +1,3 @@ common-obj-$(CONFIG_DIMM) +=3D pc-dimm.o -common-obj-$(CONFIG_MEM_DEVICE) +=3D memory-device.o +common-obj-y +=3D memory-device.o common-obj-$(CONFIG_NVDIMM) +=3D nvdimm.o --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927776; cv=none; d=zoho.com; s=zohoarc; b=LwxLvL4v2yF3qmnhFMmYS86YdnGE0ctRDbvlPPkbKeJCumcDyiquByHdnw9W2HCahrt5CXuuj1/yJ7+LWp8/SN0fmbWe/avYdD1LIF/CZSsBaXD5XGz0We+A9S34cqpG8dji3sxFgvrxnPyAXNmGIaGKWhu+Rx92Qnufi8YhEcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927776; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yXqREab8+Dht8ov84n50u33TUba4e4JzVsBJv+Jjg+k=; b=h38JVv0jbgXZwRjhPxO1YBuY+phFSRD5Ij64h9baTjcURQ43WeB3Aodo53wtUM0xcSToiRjWrNLVLJDC+Avosv6iI+hMFXrRuLYxYoYO/B2yJ+y9EnGRdOjhaBJ2Ct6hZACQgD87MX80OCLmyPycxzhMWA+w6WKpl50SSIMXEJ4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927776917720.0838442302025; Thu, 24 Oct 2019 07:36:16 -0700 (PDT) Received: from localhost ([::1]:44372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeDn-0008JA-3c for importer@patchew.org; Thu, 24 Oct 2019 10:36:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdim-0007DH-Mp for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdih-0007do-0L for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:12 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:34927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdig-0007cd-Pl for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: by mail-wr1-x42f.google.com with SMTP id l10so25813771wrb.2 for ; Thu, 24 Oct 2019 07:04:06 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yXqREab8+Dht8ov84n50u33TUba4e4JzVsBJv+Jjg+k=; b=KWwi/RvL2ZE8LcP1Ah3xM7VL8nv5WEwfRy+DSqaL/hTvEI/ivcQMXfyJxwMI6NUJXm 47ExC9L4qgeNMv/x92inQBJmaSru24W8o9BzagFVIoKSOLwZVgmVOcd2ZGtHtAAv9/tU CzC2x3lbJQDM84l6pneKDZxIfZEyaJGrkaoj3CAMMvOc/iFR8TXDGbvSYKzMwQKNBR2z FnOh91ZmGebNsKY1POPQwSoOs/vwy2+TPZbg1TbHbH5D4fHtzxjRVv/FNVw0FRE2ySH8 DjN7o01ulbm7tcQf4XbtgOnhV7TIi5SXPRJ6yeJq/C0FJkQ5eHZFTGWuK2XNTEeqtalY CIUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yXqREab8+Dht8ov84n50u33TUba4e4JzVsBJv+Jjg+k=; b=lSCSgs0FShz+RUmcQxHgKzbXNWnbB1Iw8tDKzd8dYG++3eWFqUNW4i8c0HpXN3E9m5 xzKkKrnyxoDAFIV0QvqjJ+vY0FrOjMixwUQq8paIG+eNHgBd84riNqFbi8I2TCv92YWk FcXXFJH+6J/lIazOZ5RJjcawMaeLuEKAoZAF38GCH8ZboxgzTKCErqaQsMfLlkKeXlEi PAt7DPM5lXgH6bx7AI0HpO6OYHbmnTwxug95BdJio638RBNoq3NxiFo13ZUHxm/Iz4S5 Hv1IWisZ2oSgG8VE/2pL6XWHe7aOmPgkXgyhdBkWKN0v8zsYXl/tnVlYDl4zDp1jHZkU Z5BQ== X-Gm-Message-State: APjAAAXSjq09jhkHPqmrjW2x+u5Y50evay9klM/GoNzdVybUKU8ZS36Y c2yoD2Ye3ykCk1nofDXQGy7Lg/E5 X-Google-Smtp-Source: APXvYqyyzR9H7eU4wyqYOmmLtldLClmpsM358SNHyBTDb7Q+R1LUAqcd9JYdYoJBYB6kRFTtPeYW6g== X-Received: by 2002:a5d:6ac3:: with SMTP id u3mr4223154wrw.206.1571925845015; Thu, 24 Oct 2019 07:04:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/39] hw/virtio: Factorize virtio-mmio headers Date: Thu, 24 Oct 2019 16:03:23 +0200 Message-Id: <1571925835-31930-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Put QOM and main struct definition in a separate header file, so it can be accessed from other components. Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 48 +-------------------------- include/hw/virtio/virtio-mmio.h | 73 +++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 include/hw/virtio/virtio-mmio.h diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 3d5ca0f..94d934c 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -29,57 +29,11 @@ #include "qemu/host-utils.h" #include "qemu/module.h" #include "sysemu/kvm.h" -#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-mmio.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "trace.h" =20 -/* QOM macros */ -/* virtio-mmio-bus */ -#define TYPE_VIRTIO_MMIO_BUS "virtio-mmio-bus" -#define VIRTIO_MMIO_BUS(obj) \ - OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_MMIO_BUS) -#define VIRTIO_MMIO_BUS_GET_CLASS(obj) \ - OBJECT_GET_CLASS(VirtioBusClass, (obj), TYPE_VIRTIO_MMIO_BUS) -#define VIRTIO_MMIO_BUS_CLASS(klass) \ - OBJECT_CLASS_CHECK(VirtioBusClass, (klass), TYPE_VIRTIO_MMIO_BUS) - -/* virtio-mmio */ -#define TYPE_VIRTIO_MMIO "virtio-mmio" -#define VIRTIO_MMIO(obj) \ - OBJECT_CHECK(VirtIOMMIOProxy, (obj), TYPE_VIRTIO_MMIO) - -#define VIRT_MAGIC 0x74726976 /* 'virt' */ -#define VIRT_VERSION 2 -#define VIRT_VERSION_LEGACY 1 -#define VIRT_VENDOR 0x554D4551 /* 'QEMU' */ - -typedef struct VirtIOMMIOQueue { - uint16_t num; - bool enabled; - uint32_t desc[2]; - uint32_t avail[2]; - uint32_t used[2]; -} VirtIOMMIOQueue; - -typedef struct { - /* Generic */ - SysBusDevice parent_obj; - MemoryRegion iomem; - qemu_irq irq; - bool legacy; - /* Guest accessible state needing migration and reset */ - uint32_t host_features_sel; - uint32_t guest_features_sel; - uint32_t guest_page_shift; - /* virtio-bus */ - VirtioBusState bus; - bool format_transport_address; - /* Fields only used for non-legacy (v2) devices */ - uint32_t guest_features[2]; - VirtIOMMIOQueue vqs[VIRTIO_QUEUE_MAX]; -} VirtIOMMIOProxy; - static bool virtio_mmio_ioeventfd_enabled(DeviceState *d) { return kvm_eventfds_enabled(); diff --git a/include/hw/virtio/virtio-mmio.h b/include/hw/virtio/virtio-mmi= o.h new file mode 100644 index 0000000..7dbfd03 --- /dev/null +++ b/include/hw/virtio/virtio-mmio.h @@ -0,0 +1,73 @@ +/* + * Virtio MMIO bindings + * + * Copyright (c) 2011 Linaro Limited + * + * Author: + * Peter Maydell + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef HW_VIRTIO_MMIO_H +#define HW_VIRTIO_MMIO_H + +#include "hw/virtio/virtio-bus.h" + +/* QOM macros */ +/* virtio-mmio-bus */ +#define TYPE_VIRTIO_MMIO_BUS "virtio-mmio-bus" +#define VIRTIO_MMIO_BUS(obj) \ + OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_MMIO_BUS) +#define VIRTIO_MMIO_BUS_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VirtioBusClass, (obj), TYPE_VIRTIO_MMIO_BUS) +#define VIRTIO_MMIO_BUS_CLASS(klass) \ + OBJECT_CLASS_CHECK(VirtioBusClass, (klass), TYPE_VIRTIO_MMIO_BUS) + +/* virtio-mmio */ +#define TYPE_VIRTIO_MMIO "virtio-mmio" +#define VIRTIO_MMIO(obj) \ + OBJECT_CHECK(VirtIOMMIOProxy, (obj), TYPE_VIRTIO_MMIO) + +#define VIRT_MAGIC 0x74726976 /* 'virt' */ +#define VIRT_VERSION 2 +#define VIRT_VERSION_LEGACY 1 +#define VIRT_VENDOR 0x554D4551 /* 'QEMU' */ + +typedef struct VirtIOMMIOQueue { + uint16_t num; + bool enabled; + uint32_t desc[2]; + uint32_t avail[2]; + uint32_t used[2]; +} VirtIOMMIOQueue; + +typedef struct { + /* Generic */ + SysBusDevice parent_obj; + MemoryRegion iomem; + qemu_irq irq; + bool legacy; + /* Guest accessible state needing migration and reset */ + uint32_t host_features_sel; + uint32_t guest_features_sel; + uint32_t guest_page_shift; + /* virtio-bus */ + VirtioBusState bus; + bool format_transport_address; + /* Fields only used for non-legacy (v2) devices */ + uint32_t guest_features[2]; + VirtIOMMIOQueue vqs[VIRTIO_QUEUE_MAX]; +} VirtIOMMIOProxy; + +#endif --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929819; cv=none; d=zoho.com; s=zohoarc; b=AdxmOYyv1W+TD4u9n2LRR5rg/Vli4fMBjqx/edJB6AtRjig+mkvIKEh+P602pdKyHDrBq+WSrmp3me+oSxHV4AibdJL+dTQD8WortzEV37wwLGb5aDEGVnCqBZC+aukW5Yhouh5K8twxP8y5GZx2LGnpLLhIDBCdxVxlosNmlcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929819; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aHMT2RmStBudCWNCIOuhp+PQb1yFu2fWEBeieC/7ws8=; b=e669jvkGh9wkAeCp4ZZxMiDtJKUcXCmDKmxC1oHF/PHPXsA3AOE4qgly7zF+vKW2tyrbd4K/hLu6uNhGUvwdQSQJx6HBymQOyY4nrOt9EhR9me53M6EglkvHyUR9PQBWm5YaN7X8SIydD3fI1ZnCH6cyJOXcvb2EEZ8Lx89BecU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157192981964546.04146060401615; Thu, 24 Oct 2019 08:10:19 -0700 (PDT) Received: from localhost ([::1]:45180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNekh-0004Rg-Dd for importer@patchew.org; Thu, 24 Oct 2019 11:10:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34660) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdij-00075A-LP for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdih-0007eP-Rm for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:09 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:46832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdih-0007dl-Jk for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:07 -0400 Received: by mail-wr1-x42a.google.com with SMTP id n15so15443696wrw.13 for ; Thu, 24 Oct 2019 07:04:07 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aHMT2RmStBudCWNCIOuhp+PQb1yFu2fWEBeieC/7ws8=; b=WiRufVywNpU+Z4aWXn+upt4fMizH8PkEaX8706XkSw/4W+8/lvBWkvXdnPdU9iPcfK mINAarbhhMIgL8trXbXBDznjHz8psAZtSIA2H7gzT0Oe8dErFjWBSsUSKNC12Te+0FrO ZRuTdM6NWw06pyXjr7EdYsVlGRc58yZNyzesIO8hFv0IIelUSkxe0b3GlD+J9HN0i/Ap 06laKCjSMn9ywz986cOzzBBtnzBoibbdpeVnp7FTPSZdGPjPIGjIYfHrRoYZFu+cYQXP Sz7uxQ0ASgt2AexOj9o7bHMAyr7yx2oqVovMglg1vNX2Zy+YWGWZAf2tnf9kqXW5IAfz i6ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aHMT2RmStBudCWNCIOuhp+PQb1yFu2fWEBeieC/7ws8=; b=RPVnNopGtpmZvzRmqDCQ45YoTtoCBQbEXltoxgA/KUPzbva4OzkoMMDmvEhgEoyfXK VT3hn94S8vwWY1vEV4GWv35oHRAQSgzPgaOhvhXSKe21XCAvI+AhKcKoF99NfteOBqqn NAACNbkkiw4/F7NprJBfcTt/VSz5JjX3qVd9kpXr1a0ClY29BRFkUNHChhdCFKVi4Jja iS/Hm7EWgUgYR20hngzvKQ95NjM+gUn6MFWYngHZVwpzwoARrFSY4i5ksRpTph7nBo5x REVMGoue/CdAJQT+6TEXyJgKfNnbnSndQjV1JH4WYW6aY6PZLrUt6Y9YNXaDWl299bUW oClQ== X-Gm-Message-State: APjAAAWDz9SWfXprYHqeabRWUY5zQcudeZhZsc/TFZfnroNp6qXnoteO vQXiUFI6FPIqP6JrM+3bhbB7PIXv X-Google-Smtp-Source: APXvYqwTwLX2vJwrTqgCpJZ4YZJubyQOw22H3TeM8UADba6bi96WEOWh8kK9WfzNMbBgRajEqj7NoQ== X-Received: by 2002:a05:6000:343:: with SMTP id e3mr2572558wre.20.1571925846115; Thu, 24 Oct 2019 07:04:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/39] hw/i386/pc: rename functions shared with non-PC machines Date: Thu, 24 Oct 2019 16:03:24 +0200 Message-Id: <1571925835-31930-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez The following functions are named *pc* but are not PC-machine specific but generic to the X86 architecture, rename them: load_linux -> x86_load_linux pc_new_cpu -> x86_new_cpu pc_cpus_init -> x86_cpus_init pc_cpu_index_to_props -> x86_cpu_index_to_props pc_get_default_cpu_node_id -> x86_get_default_cpu_node_id pc_possible_cpu_arch_ids -> x86_possible_cpu_arch_ids old_pc_system_rom_init -> x86_system_rom_init Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin --- hw/i386/pc.c | 28 ++++++++++++++-------------- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/pc_sysfw.c | 6 +++--- include/hw/i386/pc.h | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4b19042..1c27223 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1019,8 +1019,8 @@ static bool load_elfboot(const char *kernel_filename, return true; } =20 -static void load_linux(PCMachineState *pcms, - FWCfgState *fw_cfg) +static void x86_load_linux(PCMachineState *pcms, + FWCfgState *fw_cfg) { uint16_t protocol; int setup_size, kernel_size, cmdline_size; @@ -1374,7 +1374,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int= level) } } =20 -static void pc_new_cpu(PCMachineState *pcms, int64_t apic_id, Error **errp) +static void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **err= p) { Object *cpu =3D NULL; Error *local_err =3D NULL; @@ -1490,14 +1490,14 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t= id, Error **errp) return; } =20 - pc_new_cpu(PC_MACHINE(ms), apic_id, &local_err); + x86_cpu_new(PC_MACHINE(ms), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); return; } } =20 -void pc_cpus_init(PCMachineState *pcms) +void x86_cpus_init(PCMachineState *pcms) { int i; const CPUArchIdList *possible_cpus; @@ -1518,7 +1518,7 @@ void pc_cpus_init(PCMachineState *pcms) ms->smp.max_cpus - 1)= + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < ms->smp.cpus; i++) { - pc_new_cpu(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); + x86_cpu_new(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); } } =20 @@ -1621,7 +1621,7 @@ void xen_load_linux(PCMachineState *pcms) fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); rom_set_fw(fw_cfg); =20 - load_linux(pcms, fw_cfg); + x86_load_linux(pcms, fw_cfg); for (i =3D 0; i < nb_option_roms; i++) { assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") || @@ -1756,7 +1756,7 @@ void pc_memory_init(PCMachineState *pcms, } =20 if (linux_boot) { - load_linux(pcms, fw_cfg); + x86_load_linux(pcms, fw_cfg); } =20 for (i =3D 0; i < nb_option_roms; i++) { @@ -2681,7 +2681,7 @@ static void pc_machine_wakeup(MachineState *machine) } =20 static CpuInstanceProperties -pc_cpu_index_to_props(MachineState *ms, unsigned cpu_index) +x86_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(ms); @@ -2690,7 +2690,7 @@ pc_cpu_index_to_props(MachineState *ms, unsigned cpu_= index) return possible_cpus->cpus[cpu_index].props; } =20 -static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx) +static int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) { X86CPUTopoInfo topo; PCMachineState *pcms =3D PC_MACHINE(ms); @@ -2702,7 +2702,7 @@ static int64_t pc_get_default_cpu_node_id(const Machi= neState *ms, int idx) return topo.pkg_id % ms->numa_state->num_nodes; } =20 -static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) +static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) { PCMachineState *pcms =3D PC_MACHINE(ms); int i; @@ -2804,9 +2804,9 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D pc_get_hotplug_handler; mc->hotplug_allowed =3D pc_hotplug_allowed; - mc->cpu_index_to_instance_props =3D pc_cpu_index_to_props; - mc->get_default_cpu_node_id =3D pc_get_default_cpu_node_id; - mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; + mc->cpu_index_to_instance_props =3D x86_cpu_index_to_props; + mc->get_default_cpu_node_id =3D x86_get_default_cpu_node_id; + mc->possible_cpu_arch_ids =3D x86_possible_cpu_arch_ids; mc->auto_enable_numa_with_memhp =3D true; mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6824b72..de09e07 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -152,7 +152,7 @@ static void pc_init1(MachineState *machine, } } =20 - pc_cpus_init(pcms); + x86_cpus_init(pcms); =20 if (kvm_enabled() && pcmc->kvmclock_enabled) { kvmclock_create(); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 8fad20f..894989b 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -179,7 +179,7 @@ static void pc_q35_init(MachineState *machine) xen_hvm_init(pcms, &ram_memory); } =20 - pc_cpus_init(pcms); + x86_cpus_init(pcms); =20 kvmclock_create(); =20 diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index a9983f0..28cb1f6 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -211,7 +211,7 @@ static void pc_system_flash_map(PCMachineState *pcms, } } =20 -static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ra= m_fw) +static void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) { char *filename; MemoryRegion *bios, *isa_bios; @@ -272,7 +272,7 @@ void pc_system_firmware_init(PCMachineState *pcms, BlockBackend *pflash_blk[ARRAY_SIZE(pcms->flash)]; =20 if (!pcmc->pci_enabled) { - old_pc_system_rom_init(rom_memory, true); + x86_bios_rom_init(rom_memory, true); return; } =20 @@ -293,7 +293,7 @@ void pc_system_firmware_init(PCMachineState *pcms, =20 if (!pflash_blk[0]) { /* Machine property pflash0 not set, use ROM mode */ - old_pc_system_rom_init(rom_memory, false); + x86_bios_rom_init(rom_memory, false); } else { if (kvm_enabled() && !kvm_readonly_mem_enabled()) { /* diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 37bfd95..7082b06 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -198,7 +198,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms); void pc_register_ferr_irq(qemu_irq irq); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); =20 -void pc_cpus_init(PCMachineState *pcms); +void x86_cpus_init(PCMachineState *pcms); void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp); void pc_smp_parse(MachineState *ms, QemuOpts *opts); =20 --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928004; cv=none; d=zoho.com; s=zohoarc; b=V85ti/y7eHkGNYgQDp4JLEdZp8/wxR+CmIIX5GpjPjrz6mmAX4VZJMCC+k2qUMMARbbn77yGD8WY9XEoa+Mq62yLJkADy+2j5gYf5fFSZ6YcB2ehbzzHApJO34+BnJMIa5y505ZO3i7ugeBHoGavg9W7cVTIO2CFo3KOxiLVHK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928004; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v0QSA56OPy9BQBWnDU2EPRHFVgRB7RnoM+muLYIJbUU=; b=ofWSRFMh1YBWg+KYYEoAsr5ndmiXMlhbSkF59E6vx5J0Hp9bhBoGrXWYNRUW+P/Cl9pLfbO05h1Dr52Hz/9mH72zCrefj3EDYIRTCkPlrf3FEBnIihI9YGDiK4tBDefh7V1BsgXERFyIcLtEa4iwAd3xB/HgRNFZa04wF0J79/o= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928004812135.01873854346002; Thu, 24 Oct 2019 07:40:04 -0700 (PDT) Received: from localhost ([::1]:44424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeHS-0006aV-Py for importer@patchew.org; Thu, 24 Oct 2019 10:40:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34698) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdio-0007LP-GD for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdij-0007ez-66 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:14 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40870) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdii-0007eZ-Js for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:09 -0400 Received: by mail-wm1-x343.google.com with SMTP id w9so1561844wmm.5 for ; Thu, 24 Oct 2019 07:04:08 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v0QSA56OPy9BQBWnDU2EPRHFVgRB7RnoM+muLYIJbUU=; b=dUzWGVQGnZCdCwxr2b5IGOJE5hxvZsPNYxszBikPz0s2aEoMJV0YbTDbNIO5iaass9 fsFiW7pzI+GMCdahEk+olYYSM2jO/5vRFGTR/5UZSbTXoa+uhIUW7vz2XmrqtqUuUUtU abSELmClPQF+c28jm1CUmGTo3LnLAoh6dGWDKbPMwHefe3iFERYBtWiYejAn460dc0KA vgFIrcBnE33Jo8LTa9SNccgTTtk3Rf3plJtDbHavTFAfDvV0PiaSVtHmDiK5hn66FFOt 2I9TVBIUQbkvmJuoEHBQ05LCpkccyYYpzOlBM2m8nta/bqOsemmPpYaTnPIq8148aA+v 6+EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=v0QSA56OPy9BQBWnDU2EPRHFVgRB7RnoM+muLYIJbUU=; b=iVJ1PtixpK8q1W5ECUWmBXFWqrsQWs3nxpi79qsmPy5g8Olv7bPM8zBIOeTxharifI E8eEZBsGGhr6eiVapFGB86xddlAla5BGH440s+td0R4pk0Vs7826V+VzyPv4H0YKv0th NSHinCJB6bXl50InJkKYipdcyxhZMIn7wF+d3OQ8Wwr4x6kuL89J0fB7A8ToWcvhVOo+ BmH5It1nr8luwgLkqrXqnhPyTgXalkfioJlp5wa6pdIATsm3GqCjimmY+zXHN0j71mPQ zVYJWKW/8jfVXqZvELAjqISfYJGQXPa9BYgecqm6Y4SW4d5fC5Y1Zp00CHqXHBn/C+m2 QCCw== X-Gm-Message-State: APjAAAVojsB14wV9g2pvpkq7jUotVRNG+xRVKrsRXXB2ZQeXsPQByaqQ LmDvibNNyMEsjLWF+DOT0BhtGZCZ X-Google-Smtp-Source: APXvYqzmzQXSFXNXHxhMGtzkXCbQ0TsBATzttosZz6W1ijF9+/lY2t1PrCEBXF3vSbiXuH9r+JLBsQ== X-Received: by 2002:a7b:ce12:: with SMTP id m18mr4876158wmc.35.1571925847244; Thu, 24 Oct 2019 07:04:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/39] hw/i386/pc: fix code style issues on functions that will be moved out Date: Thu, 24 Oct 2019 16:03:25 +0200 Message-Id: <1571925835-31930-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Fix code style issues detected by checkpatch.pl on functions that will be moved out to x86.c. Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 1c27223..75a97c2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -866,7 +866,8 @@ static void handle_a20_line_change(void *opaque, int ir= q, int level) x86_cpu_set_a20(cpu, level); } =20 -/* Calculates initial APIC ID for a specific CPU index +/* + * Calculates initial APIC ID for a specific CPU index * * Currently we need to be able to calculate the APIC ID from the CPU index * alone (without requiring a CPU object), as the QEMU<->Seabios interface= s have @@ -1039,7 +1040,7 @@ static void x86_load_linux(PCMachineState *pcms, const char *kernel_cmdline =3D machine->kernel_cmdline; =20 /* Align to 16 bytes as a paranoia measure */ - cmdline_size =3D (strlen(kernel_cmdline)+16) & ~15; + cmdline_size =3D (strlen(kernel_cmdline) + 16) & ~15; =20 /* load the kernel header */ f =3D fopen(kernel_filename, "rb"); @@ -1055,8 +1056,8 @@ static void x86_load_linux(PCMachineState *pcms, #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif - if (ldl_p(header+0x202) =3D=3D 0x53726448) { - protocol =3D lduw_p(header+0x206); + if (ldl_p(header + 0x202) =3D=3D 0x53726448) { + protocol =3D lduw_p(header + 0x206); } else { /* * This could be a multiboot kernel. If it is, let's stop treating= it @@ -1158,7 +1159,7 @@ static void x86_load_linux(PCMachineState *pcms, =20 /* highest address for loading the initrd */ if (protocol >=3D 0x20c && - lduw_p(header+0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) { + lduw_p(header + 0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) { /* * Linux has supported initrd up to 4 GB for a very long time (200= 7, * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013), @@ -1177,7 +1178,7 @@ static void x86_load_linux(PCMachineState *pcms, */ initrd_max =3D UINT32_MAX; } else if (protocol >=3D 0x203) { - initrd_max =3D ldl_p(header+0x22c); + initrd_max =3D ldl_p(header + 0x22c); } else { initrd_max =3D 0x37ffffff; } @@ -1187,14 +1188,14 @@ static void x86_load_linux(PCMachineState *pcms, } =20 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1); + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1= ); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); =20 if (protocol >=3D 0x202) { - stl_p(header+0x228, cmdline_addr); + stl_p(header + 0x228, cmdline_addr); } else { - stw_p(header+0x20, 0xA33F); - stw_p(header+0x22, cmdline_addr-real_addr); + stw_p(header + 0x20, 0xA33F); + stw_p(header + 0x22, cmdline_addr - real_addr); } =20 /* handle vga=3D parameter */ @@ -1212,20 +1213,22 @@ static void x86_load_linux(PCMachineState *pcms, } else { video_mode =3D strtol(vmode, NULL, 0); } - stw_p(header+0x1fa, video_mode); + stw_p(header + 0x1fa, video_mode); } =20 /* loader type */ - /* High nybble =3D B reserved for QEMU; low nybble is revision number. - If this code is substantially changed, you may want to consider - incrementing the revision. */ + /* + * High nybble =3D B reserved for QEMU; low nybble is revision number. + * If this code is substantially changed, you may want to consider + * incrementing the revision. + */ if (protocol >=3D 0x200) { header[0x210] =3D 0xB0; } /* heap */ if (protocol >=3D 0x201) { - header[0x211] |=3D 0x80; /* CAN_USE_HEAP */ - stw_p(header+0x224, cmdline_addr-real_addr-0x200); + header[0x211] |=3D 0x80; /* CAN_USE_HEAP */ + stw_p(header + 0x224, cmdline_addr - real_addr - 0x200); } =20 /* load initrd */ @@ -1257,14 +1260,14 @@ static void x86_load_linux(PCMachineState *pcms, exit(1); } =20 - initrd_addr =3D (initrd_max-initrd_size) & ~4095; + initrd_addr =3D (initrd_max - initrd_size) & ~4095; =20 fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_s= ize); =20 - stl_p(header+0x218, initrd_addr); - stl_p(header+0x21c, initrd_size); + stl_p(header + 0x218, initrd_addr); + stl_p(header + 0x21c, initrd_size); } =20 /* load kernel and setup */ @@ -1272,7 +1275,7 @@ static void x86_load_linux(PCMachineState *pcms, if (setup_size =3D=3D 0) { setup_size =3D 4; } - setup_size =3D (setup_size+1)*512; + setup_size =3D (setup_size + 1) * 512; if (setup_size > kernel_size) { fprintf(stderr, "qemu: invalid kernel header\n"); exit(1); @@ -1310,7 +1313,7 @@ static void x86_load_linux(PCMachineState *pcms, kernel_size =3D setup_data_offset + sizeof(struct setup_data) + dt= b_size; kernel =3D g_realloc(kernel, kernel_size); =20 - stq_p(header+0x250, prot_addr + setup_data_offset); + stq_p(header + 0x250, prot_addr + setup_data_offset); =20 setup_data =3D (struct setup_data *)(kernel + setup_data_offset); setup_data->next =3D 0; @@ -1507,7 +1510,8 @@ void x86_cpus_init(PCMachineState *pcms) =20 x86_cpu_set_default_version(pcmc->default_cpu_version); =20 - /* Calculates the limit to CPU APIC ID values + /* + * Calculates the limit to CPU APIC ID values * * Limit for the APIC ID value, so that all * CPU APIC IDs are < pcms->apic_id_limit. @@ -2712,7 +2716,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids= (MachineState *ms) /* * make sure that max_cpus hasn't changed since the first use, i.e. * -smp hasn't been parsed after it - */ + */ assert(ms->possible_cpus->len =3D=3D max_cpus); return ms->possible_cpus; } @@ -2725,7 +2729,8 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids= (MachineState *ms) =20 ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; - ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= pcms, i); + ms->possible_cpus->cpus[i].arch_id =3D + x86_cpu_apic_id_from_index(pcms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, pcms->smp_dies, ms->smp.cores, ms->smp.threads, &topo); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929977; cv=none; d=zoho.com; s=zohoarc; b=C+KvA+YiWa27ObKhA0vuWnERJe/BkKFXbndEMZGgrQ0L2aGTqPuVqsQ4w0mZWult0XPyZfCcBzVNagt9v9CwTLqH2IlpUewbmW3pHXHDRniDrNFp5x6Jbw7ssq7no1upvwCYImbHBvFK/tOCtb6tVhYiu0Nx+hidggLFZd8zkd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929977; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XLu8pI7WGdyihkGj3zvR1VjIQBcJDdmLEAnpGb6JmbI=; b=oY/0N7nHS2EBxs2yv/jn02+rDD3G62+UWl24mJQjmsUanB0R2DXRUOEMFr3D1ANOCSm1JbykClXgiuUNXHYOunCZCunHrqq330Ay+ydT/57LLPPBU07DUdJ+z2sfxc6w2qt/9MvOu+pMsT99/ZMYc0VyeZFTdoszsdRHMAwJ8cw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571929977868376.19670980575415; Thu, 24 Oct 2019 08:12:57 -0700 (PDT) Received: from localhost ([::1]:45192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNenI-0008E0-EG for importer@patchew.org; Thu, 24 Oct 2019 11:12:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34683) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdim-0007DL-Ns for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdil-0007fj-Jx for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:12 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdil-0007fO-Dv for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:11 -0400 Received: by mail-wr1-x443.google.com with SMTP id o28so26220755wro.7 for ; Thu, 24 Oct 2019 07:04:10 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XLu8pI7WGdyihkGj3zvR1VjIQBcJDdmLEAnpGb6JmbI=; b=ro1JCFa7K7/sOdiZQmuLBW2JMyn/QVKeYTyTRkPLNC4ZI26s00byG38j95twkdfBsq g1mbTjrSS+TPifWtdtiJQYbRQkBD6LP1l2JGv+dn373Q+twMuCK1Sebhs76mKvSYAIUa RMXhbSYSdG0ESnCa+9OEBgxUWAMC10BZT9vgkYcZm7V80NvgG14H6pw+N9qXoHMLS4Dx hc2U3tLxARs+jLOCKvwtNay0/FWrMtPbdjKL/47NRWkuFR61A304nqZ3ESRCFjWTK5dS MyHfiytNvbEbRVVro4WGJBVfsQD8I/Qmr1uDQdY5XFgI4+WaBDlZY5lmUn9X/aFiNOky fNrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XLu8pI7WGdyihkGj3zvR1VjIQBcJDdmLEAnpGb6JmbI=; b=rnyY5hg31asRbYB8jIGW1u/X94w3mXWjNUvsGq8FKC+1BmP+gVBOJ5OMTXXJVyPV92 w7AaTdc4DPawS52IXepNyNV0uJU/RzV94Y6ZnkbbheR0e06R24u41L4LXE4V2UMUm20R 8Q0a9LnmUala+17O2IZeTQLqw3fR8xFSvTlLJB+WWkR74npNYHgmVM/T1Rfvirti68jQ 10eqky0+b9lWBxtuXItLHeYv14hjWRkT7JLn/XCDLGkzhydVJCR4uo0cRiyQNhbXC41o Z/kpqCHy3mUn+ApeSmJJozOJBDAbrdyLcOQJmES4R/lDdZs6AiM5xzxnvbkbcAq97cy1 iYPA== X-Gm-Message-State: APjAAAXmW5qc+IupCkw4q86eburKKgDn60jvKSCUg0wi1KYuqLcjjtB1 ZXozG27AaJDuK159aq4ADQWBeGK1 X-Google-Smtp-Source: APXvYqxY0MuMFPY+fnBWfrA2mFZz+HiRjMfhzJ2FJgXJ6/tYbCxBCibh9wEPiSqbBl1EkZGZJvf3sw== X-Received: by 2002:adf:9185:: with SMTP id 5mr4252458wri.389.1571925849710; Thu, 24 Oct 2019 07:04:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/39] hw/i386/pc: replace use of strtol with qemu_strtoui in x86_load_linux() Date: Thu, 24 Oct 2019 16:03:26 +0200 Message-Id: <1571925835-31930-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Follow checkpatch.pl recommendation and replace the use of strtol with qemu_strtoui in x86_load_linux(). Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 75a97c2..b5b660f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -68,6 +68,7 @@ #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qemu/cutils.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/boards.h" @@ -1202,6 +1203,7 @@ static void x86_load_linux(PCMachineState *pcms, vmode =3D strstr(kernel_cmdline, "vga=3D"); if (vmode) { unsigned int video_mode; + int ret; /* skip "vga=3D" */ vmode +=3D 4; if (!strncmp(vmode, "normal", 6)) { @@ -1211,7 +1213,12 @@ static void x86_load_linux(PCMachineState *pcms, } else if (!strncmp(vmode, "ask", 3)) { video_mode =3D 0xfffd; } else { - video_mode =3D strtol(vmode, NULL, 0); + ret =3D qemu_strtoui(vmode, NULL, 0, &video_mode); + if (ret !=3D 0) { + fprintf(stderr, "qemu: can't parse 'vga' parameter: %s\n", + strerror(-ret)); + exit(1); + } } stw_p(header + 0x1fa, video_mode); } --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930726; cv=none; d=zoho.com; s=zohoarc; b=d/3Ldo6d2Q9v28aWyAhXunbxs7HegRMTfz6FUg+H2ETDm2YE7/saUZ3P9JeGrae62+eRCf9svXS8+D0hGZlKJoO/EBwcQCN5k0+/N1uk1nihVzJ5+tcmUKxuNYbHYm+6Iw1O4WWjyewWDnAF0Hlg4lMz/qP+kPcDv7e9wKUYSKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930726; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dj03/Yqw2HLWY4su1lbnJ5oTSp3WYGgIZYAiK8OHCfc=; b=ADjxmLUehzRn/LeH5nS3IGrPpYnJOaIJGpuIFIrHiWD6fdDCcSSIyV4s8aE04DtjUvrsKEq26U0tguiKPmwmx0940HEOLfv0m11r791KwjjcBtRsKUYuEPFB07Cr1DQMZJvdKkQK7UX/WWAwS1NcRxdV5jxBIcvCUBgOJFXvCtA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930726530256.31854799731536; Thu, 24 Oct 2019 08:25:26 -0700 (PDT) Received: from localhost ([::1]:45372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNezN-0008HZ-8r for importer@patchew.org; Thu, 24 Oct 2019 11:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34717) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdir-0007aO-QB for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdim-0007g9-Es for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:17 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdim-0007ff-4x for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:12 -0400 Received: by mail-wr1-x442.google.com with SMTP id q13so21264718wrs.12 for ; Thu, 24 Oct 2019 07:04:12 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dj03/Yqw2HLWY4su1lbnJ5oTSp3WYGgIZYAiK8OHCfc=; b=sa/u5UXvW7bIAM29nT9SfCwoR7RUZ2o7/pJsXRH+pZ0ffKo0o14IHybwhGly5ZUQDp nX88YRQbX6wpv/MMDWzp4lX4XbIMoy7qpXoCDoD/nqPkaq2UHNJUkAwWkrih4066F3Bv sT5mam9r7EdqhCzAR+Ap7Wne8A8j2vP9NTnx/v+DOYtoSI7MfDDMt+w7LlqSw9GH0yBR kZFl+CcyNjSMFlRV8lA7A59daX/itt1X+SVRv1ywh8/z2jAVIB1orpkaVQVv5Gy1FFDk SqOcgSfJPvjcjikNLJ9PxZ4LyB2YR6U1QH6x3oDp0wlnQTtc/OYFxy3muZgizkC2wELl 4hWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Dj03/Yqw2HLWY4su1lbnJ5oTSp3WYGgIZYAiK8OHCfc=; b=hN9W3vF8DBi6TRVzeX3B0bYFuNwsojJR3vu1JF25tzkdA1UnvHhNRamG9z8uWfhLIp tX7rUq2c7JZUgbpEcNWJQ3V9B6SI03h2C4o7qOBxSo+7ZveFY22qR9i1EInFzwEH4nZJ zWzymo3cxxFAWekIvMdJJ2unSQvjZfAIEwKqbBmyu+y/1BEFsULvHXmUmypdZJ0oiwLZ Ye0ajJ3gaApTBCYLt8Gfg9eaY0pODj2y5HSmxkDoADGnCE/VnSqhx7t4HzUalars3K/R nKe1GPTjVefmMX2gdLgZj3TlABQEKqlQXLf8VrBFBROBB19sI58hUikie/df8ENV3J5j pd3Q== X-Gm-Message-State: APjAAAUlT1NDf/U7iPRZdae7BdDF49JXFPKaInkOKF4cjNXI5INxHO94 6Q6tYPNYZyDrvj3wjEUomh6kR+d9 X-Google-Smtp-Source: APXvYqxfzqKCxNokxBjtcaDfEc8Hfe8IVUZwHnBiWJ+CJ2qMwXS6gNcWpgckElSEocsbLsOC2kcG7Q== X-Received: by 2002:adf:9c81:: with SMTP id d1mr3871019wre.238.1571925850869; Thu, 24 Oct 2019 07:04:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/39] hw/i386/pc: avoid an assignment in if condition in x86_load_linux() Date: Thu, 24 Oct 2019 16:03:27 +0200 Message-Id: <1571925835-31930-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Follow checkpatch.pl recommendation and avoid an assignment in if condition in x86_load_linux(). Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b5b660f..77198d5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1045,7 +1045,14 @@ static void x86_load_linux(PCMachineState *pcms, =20 /* load the kernel header */ f =3D fopen(kernel_filename, "rb"); - if (!f || !(kernel_size =3D get_file_size(f)) || + if (!f) { + fprintf(stderr, "qemu: could not open kernel file '%s': %s\n", + kernel_filename, strerror(errno)); + exit(1); + } + + kernel_size =3D get_file_size(f); + if (!kernel_size || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=3D MIN(ARRAY_SIZE(header), kernel_size)) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930933; cv=none; d=zoho.com; s=zohoarc; b=oXWHyV95Mnp4lm22qTutiGHPLXsI2/FEx/D/06jea0EicJ5iitpGNdLXOrw/kSReqRYanl+DSMS2hk8O2yBXFEsJxJrhi1Ohg+UCGaa6tiJZB3R5meYRHw4OdrU2alvsTnejOJu6lSH1PBwOsAVxeFhd345veAb4iETcHFq3GZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930933; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8c/3/yDPtbmBA5j6HPKqTm5tEp67D1/8CMXeibduBpY=; b=L9daKgf452LE8/8l3/dYOvkejSDXf/iR9l6Vkm9mFz7xzo2aJhY5eOdVyBRjhN/JYMDmQ4shfUeWwcbkwiAgE0dH8yKeKpIctQEKEAtsv1aP5tgWYtsKYwNTghR2cDwYTVHztwPX/Q76t2jmVbVJSfSsvEfv7RYY0j6YVn6aP5U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930933783795.6390573417665; Thu, 24 Oct 2019 08:28:53 -0700 (PDT) Received: from localhost ([::1]:45406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf2e-0002cn-MV for importer@patchew.org; Thu, 24 Oct 2019 11:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdit-0007im-Ni for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdio-0007h0-Lj for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdio-0007gH-Cp for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:14 -0400 Received: by mail-wr1-x443.google.com with SMTP id n15so15444067wrw.13 for ; Thu, 24 Oct 2019 07:04:13 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8c/3/yDPtbmBA5j6HPKqTm5tEp67D1/8CMXeibduBpY=; b=EIguV4hmi4rSCjBXMEW8soNlceIS4yXE49wVCQQh3SRbc8n+1xC+coO10jeQoi7nIb C5zbyukq6kFQDyMf4niIzM74rMzqMI4pcya+taVsFn098yrcvWjZyf0N3LXoADnhuNiR 5Lj6yKLdnWdFrduAZq8q+nZRcay9ML4vieUrVzlWNtl3UEz9H1+TVjf5EVyPR6UpaB3g Kpo5G6kTnthI8UHVwy343DEoQzTVdHK3xeJXr1xbdT2cIIkPV/l4XqpyEatY3IxfVwca d0LGCZ0tkE/MItCBpr51VA+toJ3qIeoNyfJEmc208KEnAMCvShmDNU49nPlVxQ44RKDa khdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8c/3/yDPtbmBA5j6HPKqTm5tEp67D1/8CMXeibduBpY=; b=KL7LCxJ2GSBjlh/kRd5+4+RzT/aWqCdu6cDwKdKmpzLpuNfOqB4yFQU5pWhOBQd/G4 WpWbnPAcLL7e0byUKJiSeCPFB0Oo3P4anMAc2If2x/VXODVcFaUFuT39voyxP8n5LvNu nz5MHmakuUMxB0IS8yFZZPcRVlDMMCa4REe8AbvxBJnuosbaY1TdBOkW8h1E/gkJC+GF hRsv9LZLRlZdBw2pWGHXgnpXKnGoHKzJSEZ2zplkxh6mi/PFmpyi0evZsrM4fERJWlH7 mB21pwUCco/70h6AYg/LhDL9rs4bca4RtkSYxSsr19m+pvyijWgglLAD2E0mVS05R0wm y/Tw== X-Gm-Message-State: APjAAAU/gYkm/LPMj4Eg1M3LR9oloNWuBqM9tV3KQPXHarNLu8FKK+1N Btzl5B4yFkTX+VC/PExf0Lo54KgU X-Google-Smtp-Source: APXvYqxPwG9m1rXXM7N7w1+gA0X+PG5MSgUd6/xLEp6kWk3xus11d+F3g+3f2hhuhrc34oqzhjR6Ew== X-Received: by 2002:a5d:638c:: with SMTP id p12mr3754421wru.136.1571925851806; Thu, 24 Oct 2019 07:04:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/39] hw/i386/pc: remove commented out code from x86_load_linux() Date: Thu, 24 Oct 2019 16:03:28 +0200 Message-Id: <1571925835-31930-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Follow checkpatch.pl recommendation and remove commented out code from x86_load_linux(). Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 77198d5..903bc05 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1061,9 +1061,6 @@ static void x86_load_linux(PCMachineState *pcms, } =20 /* kernel protocol version */ -#if 0 - fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); -#endif if (ldl_p(header + 0x202) =3D=3D 0x53726448) { protocol =3D lduw_p(header + 0x206); } else { @@ -1155,16 +1152,6 @@ static void x86_load_linux(PCMachineState *pcms, prot_addr =3D 0x100000; } =20 -#if 0 - fprintf(stderr, - "qemu: real_addr =3D 0x" TARGET_FMT_plx "\n" - "qemu: cmdline_addr =3D 0x" TARGET_FMT_plx "\n" - "qemu: prot_addr =3D 0x" TARGET_FMT_plx "\n", - real_addr, - cmdline_addr, - prot_addr); -#endif - /* highest address for loading the initrd */ if (protocol >=3D 0x20c && lduw_p(header + 0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) { --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929508; cv=none; d=zoho.com; s=zohoarc; b=cfmVDDx+a/vNtXhJGDZ8E5ScuPR6Qz+UXKIVMXhbeBwoi8MZG00Gzr/vjKaMRFdtApPUJtCiXXFnMJzAtdWGVyRvxriAfUZKlRm9soEznjG8mkJ3dR/dSkV8YQxN/2vJmKYm+7NQwMEBlqCUthzSJ6omRSwjl1Qrd9Yr9N7GUj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4LTyVRPQ+zt580ZSqWNKH9OF4awre/LXCD66B7P5FJc=; b=l8D6EVY2IrlTqfRn6xEhP70V44OEnGcVyIjiILOHXE3ra05mjNFEcG5NaAPINycZQSBAxJn50bzNW4TSPBrDFhBsBGoXtT+B6zn8CqBJ9dbc02KZUpm5tbtFuv6ShyyksEuz5VWESm/qF0n3KZFoh05boSRnVB5qHUhzPZ9wA+E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571929508588835.0534344531944; Thu, 24 Oct 2019 08:05:08 -0700 (PDT) Received: from localhost ([::1]:45032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNefi-00037T-FZ for importer@patchew.org; Thu, 24 Oct 2019 11:05:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34866) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj1-0007wh-8k for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdir-0007hs-Q3 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:26 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:34033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdip-0007h6-L7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:17 -0400 Received: by mail-wr1-x42d.google.com with SMTP id t16so21105381wrr.1 for ; Thu, 24 Oct 2019 07:04:15 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4LTyVRPQ+zt580ZSqWNKH9OF4awre/LXCD66B7P5FJc=; b=CA5u/6FMpt2nzlRAL1qhXx6Fj7MGM5+kcd4nd3efzXan4s0FYr1PkuZFluNf20umWe X49R5JnbYP1YRcUCTugNQ3W/7QG4dewRW6KMGUyKEsZLM6Z29A32A/j+oBmMBPFY64IX hVXEtTbpdHtETCCj/Gz8PJ9DCD/ossEtWk+I1T8Xcr+Nd+nb2nGGp8cHMO9ZqMJ8dGRz DgwzkTQ0aFA1gtcPavnhwNfhKWRCnQ5WhFdGf47TlKE+6wAyfWkCjWHMk20k8IDCjD7c 4sG2vKJMwZyfftMnndALbNddzBZvsYR9/Af4QxFZ3D36BDmuS05T0yt0sEp5SECLHZrX lDEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4LTyVRPQ+zt580ZSqWNKH9OF4awre/LXCD66B7P5FJc=; b=DNl9vNo/tE5YHfX0bFHAXtuVx8EpYIZrIddpPji1yTF4CbR2LnkQrlZxV4u9/8X2+V 717b7yBka/ZPuFOR/rCn934/UPEEG85AuZd58Z0GhaPe6FPzDWRgau36X0sGoZN7VdMr 2FbSi6e8ZadQx5dAVO7Y7YPeqE953Jzw86wixEyDV1jvLcmdc96bNg14ccpc9DT77KzN d3BbnLa+bTlQjsW7BBo8ysJ+VqP7AW3RfvyxzT5P2LGr/lgCroc7kHKMqb4UKHUBTFS3 Ta9GTqD1SZcqyyN38bai6MX9Iw7L4TUHy898g27LyikpOBaDrhfEPOfWyBDIQdJc5YVU ol9g== X-Gm-Message-State: APjAAAWGxwdwzeGO+YYPOXJgpQzTxzLHuUp7mi70c3UMbzA+6O/zW+u7 xJtOpXU30KJNXSMSeTbITrB5qpP2 X-Google-Smtp-Source: APXvYqyCwYt1b1ZzeSE9HXBwLwhniXh4L1NhNlAEzvn6AAADd01PNrd9R18Q2RC4h29zfDGGunsc/A== X-Received: by 2002:adf:a48c:: with SMTP id g12mr3828171wrb.212.1571925852793; Thu, 24 Oct 2019 07:04:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/39] hw/i386/pc: move shared x86 functions to x86.c and export them Date: Thu, 24 Oct 2019 16:03:29 +0200 Message-Id: <1571925835-31930-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Move x86 functions that will be shared between PC and non-PC machine types to x86.c, along with their helpers. Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin --- hw/i386/Makefile.objs | 1 + hw/i386/pc.c | 587 +----------------------------------------- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/i386/pc_sysfw.c | 56 +--- hw/i386/x86.c | 690 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ include/hw/i386/pc.h | 1 - include/hw/i386/x86.h | 35 +++ 8 files changed, 730 insertions(+), 642 deletions(-) create mode 100644 hw/i386/x86.c create mode 100644 include/hw/i386/x86.h diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index d3374e0..7ed80a4 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -1,5 +1,6 @@ obj-$(CONFIG_KVM) +=3D kvm/ obj-y +=3D e820_memory_layout.o multiboot.o +obj-y +=3D x86.o obj-y +=3D pc.o obj-$(CONFIG_I440FX) +=3D pc_piix.o obj-$(CONFIG_Q35) +=3D pc_q35.o diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 903bc05..4a1bc95 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" @@ -103,9 +104,6 @@ =20 struct hpet_fw_config hpet_cfg =3D {.count =3D UINT8_MAX}; =20 -/* Physical Address of PVH entry point read from kernel ELF NOTE */ -static size_t pvh_start_addr; - GlobalProperty pc_compat_4_1[] =3D {}; const size_t pc_compat_4_1_len =3D G_N_ELEMENTS(pc_compat_4_1); =20 @@ -867,481 +865,6 @@ static void handle_a20_line_change(void *opaque, int = irq, int level) x86_cpu_set_a20(cpu, level); } =20 -/* - * Calculates initial APIC ID for a specific CPU index - * - * Currently we need to be able to calculate the APIC ID from the CPU index - * alone (without requiring a CPU object), as the QEMU<->Seabios interface= s have - * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC = ID of - * all CPUs up to max_cpus. - */ -static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, - unsigned int cpu_index) -{ - MachineState *ms =3D MACHINE(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); - uint32_t correct_id; - static bool warned; - - correct_id =3D x86_apicid_from_cpu_idx(pcms->smp_dies, ms->smp.cores, - ms->smp.threads, cpu_index); - if (pcmc->compat_apic_id_mode) { - if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { - error_report("APIC IDs set in compatibility mode, " - "CPU topology won't match the configuration"); - warned =3D true; - } - return cpu_index; - } else { - return correct_id; - } -} - -static long get_file_size(FILE *f) -{ - long where, size; - - /* XXX: on Unix systems, using fstat() probably makes more sense */ - - where =3D ftell(f); - fseek(f, 0, SEEK_END); - size =3D ftell(f); - fseek(f, where, SEEK_SET); - - return size; -} - -struct setup_data { - uint64_t next; - uint32_t type; - uint32_t len; - uint8_t data[0]; -} __attribute__((packed)); - - -/* - * The entry point into the kernel for PVH boot is different from - * the native entry point. The PVH entry is defined by the x86/HVM - * direct boot ABI and is available in an ELFNOTE in the kernel binary. - * - * This function is passed to load_elf() when it is called from - * load_elfboot() which then additionally checks for an ELF Note of - * type XEN_ELFNOTE_PHYS32_ENTRY and passes it to this function to - * parse the PVH entry address from the ELF Note. - * - * Due to trickery in elf_opts.h, load_elf() is actually available as - * load_elf32() or load_elf64() and this routine needs to be able - * to deal with being called as 32 or 64 bit. - * - * The address of the PVH entry point is saved to the 'pvh_start_addr' - * global variable. (although the entry point is 32-bit, the kernel - * binary can be either 32-bit or 64-bit). - */ -static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) -{ - size_t *elf_note_data_addr; - - /* Check if ELF Note header passed in is valid */ - if (arg1 =3D=3D NULL) { - return 0; - } - - if (is64) { - struct elf64_note *nhdr64 =3D (struct elf64_note *)arg1; - uint64_t nhdr_size64 =3D sizeof(struct elf64_note); - uint64_t phdr_align =3D *(uint64_t *)arg2; - uint64_t nhdr_namesz =3D nhdr64->n_namesz; - - elf_note_data_addr =3D - ((void *)nhdr64) + nhdr_size64 + - QEMU_ALIGN_UP(nhdr_namesz, phdr_align); - } else { - struct elf32_note *nhdr32 =3D (struct elf32_note *)arg1; - uint32_t nhdr_size32 =3D sizeof(struct elf32_note); - uint32_t phdr_align =3D *(uint32_t *)arg2; - uint32_t nhdr_namesz =3D nhdr32->n_namesz; - - elf_note_data_addr =3D - ((void *)nhdr32) + nhdr_size32 + - QEMU_ALIGN_UP(nhdr_namesz, phdr_align); - } - - pvh_start_addr =3D *elf_note_data_addr; - - return pvh_start_addr; -} - -static bool load_elfboot(const char *kernel_filename, - int kernel_file_size, - uint8_t *header, - size_t pvh_xen_start_addr, - FWCfgState *fw_cfg) -{ - uint32_t flags =3D 0; - uint32_t mh_load_addr =3D 0; - uint32_t elf_kernel_size =3D 0; - uint64_t elf_entry; - uint64_t elf_low, elf_high; - int kernel_size; - - if (ldl_p(header) !=3D 0x464c457f) { - return false; /* no elfboot */ - } - - bool elf_is64 =3D header[EI_CLASS] =3D=3D ELFCLASS64; - flags =3D elf_is64 ? - ((Elf64_Ehdr *)header)->e_flags : ((Elf32_Ehdr *)header)->e_flags; - - if (flags & 0x00010004) { /* LOAD_ELF_HEADER_HAS_ADDR */ - error_report("elfboot unsupported flags =3D %x", flags); - exit(1); - } - - uint64_t elf_note_type =3D XEN_ELFNOTE_PHYS32_ENTRY; - kernel_size =3D load_elf(kernel_filename, read_pvh_start_addr, - NULL, &elf_note_type, &elf_entry, - &elf_low, &elf_high, 0, I386_ELF_MACHINE, - 0, 0); - - if (kernel_size < 0) { - error_report("Error while loading elf kernel"); - exit(1); - } - mh_load_addr =3D elf_low; - elf_kernel_size =3D elf_high - elf_low; - - if (pvh_start_addr =3D=3D 0) { - error_report("Error loading uncompressed kernel without PVH ELF No= te"); - exit(1); - } - fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, pvh_start_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, mh_load_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, elf_kernel_size); - - return true; -} - -static void x86_load_linux(PCMachineState *pcms, - FWCfgState *fw_cfg) -{ - uint16_t protocol; - int setup_size, kernel_size, cmdline_size; - int dtb_size, setup_data_offset; - uint32_t initrd_max; - uint8_t header[8192], *setup, *kernel; - hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =3D 0; - FILE *f; - char *vmode; - MachineState *machine =3D MACHINE(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); - struct setup_data *setup_data; - const char *kernel_filename =3D machine->kernel_filename; - const char *initrd_filename =3D machine->initrd_filename; - const char *dtb_filename =3D machine->dtb; - const char *kernel_cmdline =3D machine->kernel_cmdline; - - /* Align to 16 bytes as a paranoia measure */ - cmdline_size =3D (strlen(kernel_cmdline) + 16) & ~15; - - /* load the kernel header */ - f =3D fopen(kernel_filename, "rb"); - if (!f) { - fprintf(stderr, "qemu: could not open kernel file '%s': %s\n", - kernel_filename, strerror(errno)); - exit(1); - } - - kernel_size =3D get_file_size(f); - if (!kernel_size || - fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=3D - MIN(ARRAY_SIZE(header), kernel_size)) { - fprintf(stderr, "qemu: could not load kernel '%s': %s\n", - kernel_filename, strerror(errno)); - exit(1); - } - - /* kernel protocol version */ - if (ldl_p(header + 0x202) =3D=3D 0x53726448) { - protocol =3D lduw_p(header + 0x206); - } else { - /* - * This could be a multiboot kernel. If it is, let's stop treating= it - * like a Linux kernel. - * Note: some multiboot images could be in the ELF format (the sam= e of - * PVH), so we try multiboot first since we check the multiboot ma= gic - * header before to load it. - */ - if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, - kernel_cmdline, kernel_size, header)) { - return; - } - /* - * Check if the file is an uncompressed kernel file (ELF) and load= it, - * saving the PVH entry point used by the x86/HVM direct boot ABI. - * If load_elfboot() is successful, populate the fw_cfg info. - */ - if (pcmc->pvh_enabled && - load_elfboot(kernel_filename, kernel_size, - header, pvh_start_addr, fw_cfg)) { - fclose(f); - - fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, - strlen(kernel_cmdline) + 1); - fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); - - fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, sizeof(header)); - fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, - header, sizeof(header)); - - /* load initrd */ - if (initrd_filename) { - GMappedFile *mapped_file; - gsize initrd_size; - gchar *initrd_data; - GError *gerr =3D NULL; - - mapped_file =3D g_mapped_file_new(initrd_filename, false, = &gerr); - if (!mapped_file) { - fprintf(stderr, "qemu: error reading initrd %s: %s\n", - initrd_filename, gerr->message); - exit(1); - } - pcms->initrd_mapped_file =3D mapped_file; - - initrd_data =3D g_mapped_file_get_contents(mapped_file); - initrd_size =3D g_mapped_file_get_length(mapped_file); - initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_s= ize - 1; - if (initrd_size >=3D initrd_max) { - fprintf(stderr, "qemu: initrd is too large, cannot sup= port." - "(max: %"PRIu32", need %"PRId64")\n", - initrd_max, (uint64_t)initrd_size); - exit(1); - } - - initrd_addr =3D (initrd_max - initrd_size) & ~4095; - - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, - initrd_size); - } - - option_rom[nb_option_roms].bootindex =3D 0; - option_rom[nb_option_roms].name =3D "pvh.bin"; - nb_option_roms++; - - return; - } - protocol =3D 0; - } - - if (protocol < 0x200 || !(header[0x211] & 0x01)) { - /* Low kernel */ - real_addr =3D 0x90000; - cmdline_addr =3D 0x9a000 - cmdline_size; - prot_addr =3D 0x10000; - } else if (protocol < 0x202) { - /* High but ancient kernel */ - real_addr =3D 0x90000; - cmdline_addr =3D 0x9a000 - cmdline_size; - prot_addr =3D 0x100000; - } else { - /* High and recent kernel */ - real_addr =3D 0x10000; - cmdline_addr =3D 0x20000; - prot_addr =3D 0x100000; - } - - /* highest address for loading the initrd */ - if (protocol >=3D 0x20c && - lduw_p(header + 0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) { - /* - * Linux has supported initrd up to 4 GB for a very long time (200= 7, - * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013), - * though it only sets initrd_max to 2 GB to "work around bootload= er - * bugs". Luckily, QEMU firmware(which does something like bootloa= der) - * has supported this. - * - * It's believed that if XLF_CAN_BE_LOADED_ABOVE_4G is set, initrd= can - * be loaded into any address. - * - * In addition, initrd_max is uint32_t simply because QEMU doesn't - * support the 64-bit boot protocol (specifically the ext_ramdisk_= image - * field). - * - * Therefore here just limit initrd_max to UINT32_MAX simply as we= ll. - */ - initrd_max =3D UINT32_MAX; - } else if (protocol >=3D 0x203) { - initrd_max =3D ldl_p(header + 0x22c); - } else { - initrd_max =3D 0x37ffffff; - } - - if (initrd_max >=3D pcms->below_4g_mem_size - pcmc->acpi_data_size) { - initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_size - 1; - } - - fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1= ); - fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); - - if (protocol >=3D 0x202) { - stl_p(header + 0x228, cmdline_addr); - } else { - stw_p(header + 0x20, 0xA33F); - stw_p(header + 0x22, cmdline_addr - real_addr); - } - - /* handle vga=3D parameter */ - vmode =3D strstr(kernel_cmdline, "vga=3D"); - if (vmode) { - unsigned int video_mode; - int ret; - /* skip "vga=3D" */ - vmode +=3D 4; - if (!strncmp(vmode, "normal", 6)) { - video_mode =3D 0xffff; - } else if (!strncmp(vmode, "ext", 3)) { - video_mode =3D 0xfffe; - } else if (!strncmp(vmode, "ask", 3)) { - video_mode =3D 0xfffd; - } else { - ret =3D qemu_strtoui(vmode, NULL, 0, &video_mode); - if (ret !=3D 0) { - fprintf(stderr, "qemu: can't parse 'vga' parameter: %s\n", - strerror(-ret)); - exit(1); - } - } - stw_p(header + 0x1fa, video_mode); - } - - /* loader type */ - /* - * High nybble =3D B reserved for QEMU; low nybble is revision number. - * If this code is substantially changed, you may want to consider - * incrementing the revision. - */ - if (protocol >=3D 0x200) { - header[0x210] =3D 0xB0; - } - /* heap */ - if (protocol >=3D 0x201) { - header[0x211] |=3D 0x80; /* CAN_USE_HEAP */ - stw_p(header + 0x224, cmdline_addr - real_addr - 0x200); - } - - /* load initrd */ - if (initrd_filename) { - GMappedFile *mapped_file; - gsize initrd_size; - gchar *initrd_data; - GError *gerr =3D NULL; - - if (protocol < 0x200) { - fprintf(stderr, "qemu: linux kernel too old to load a ram disk= \n"); - exit(1); - } - - mapped_file =3D g_mapped_file_new(initrd_filename, false, &gerr); - if (!mapped_file) { - fprintf(stderr, "qemu: error reading initrd %s: %s\n", - initrd_filename, gerr->message); - exit(1); - } - pcms->initrd_mapped_file =3D mapped_file; - - initrd_data =3D g_mapped_file_get_contents(mapped_file); - initrd_size =3D g_mapped_file_get_length(mapped_file); - if (initrd_size >=3D initrd_max) { - fprintf(stderr, "qemu: initrd is too large, cannot support." - "(max: %"PRIu32", need %"PRId64")\n", - initrd_max, (uint64_t)initrd_size); - exit(1); - } - - initrd_addr =3D (initrd_max - initrd_size) & ~4095; - - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_s= ize); - - stl_p(header + 0x218, initrd_addr); - stl_p(header + 0x21c, initrd_size); - } - - /* load kernel and setup */ - setup_size =3D header[0x1f1]; - if (setup_size =3D=3D 0) { - setup_size =3D 4; - } - setup_size =3D (setup_size + 1) * 512; - if (setup_size > kernel_size) { - fprintf(stderr, "qemu: invalid kernel header\n"); - exit(1); - } - kernel_size -=3D setup_size; - - setup =3D g_malloc(setup_size); - kernel =3D g_malloc(kernel_size); - fseek(f, 0, SEEK_SET); - if (fread(setup, 1, setup_size, f) !=3D setup_size) { - fprintf(stderr, "fread() failed\n"); - exit(1); - } - if (fread(kernel, 1, kernel_size, f) !=3D kernel_size) { - fprintf(stderr, "fread() failed\n"); - exit(1); - } - fclose(f); - - /* append dtb to kernel */ - if (dtb_filename) { - if (protocol < 0x209) { - fprintf(stderr, "qemu: Linux kernel too old to load a dtb\n"); - exit(1); - } - - dtb_size =3D get_image_size(dtb_filename); - if (dtb_size <=3D 0) { - fprintf(stderr, "qemu: error reading dtb %s: %s\n", - dtb_filename, strerror(errno)); - exit(1); - } - - setup_data_offset =3D QEMU_ALIGN_UP(kernel_size, 16); - kernel_size =3D setup_data_offset + sizeof(struct setup_data) + dt= b_size; - kernel =3D g_realloc(kernel, kernel_size); - - stq_p(header + 0x250, prot_addr + setup_data_offset); - - setup_data =3D (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =3D 0; - setup_data->type =3D cpu_to_le32(SETUP_DTB); - setup_data->len =3D cpu_to_le32(dtb_size); - - load_image_size(dtb_filename, setup_data->data, dtb_size); - } - - memcpy(setup, header, MIN(sizeof(header), setup_size)); - - fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size); - - fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr); - fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size); - - option_rom[nb_option_roms].bootindex =3D 0; - option_rom[nb_option_roms].name =3D "linuxboot.bin"; - if (pcmc->linuxboot_dma_enabled && fw_cfg_dma_enabled(fw_cfg)) { - option_rom[nb_option_roms].name =3D "linuxboot_dma.bin"; - } - nb_option_roms++; -} - #define NE2000_NB_MAX 6 =20 static const int ne2000_io[NE2000_NB_MAX] =3D { 0x300, 0x320, 0x340, 0x360, @@ -1378,24 +901,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int= level) } } =20 -static void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **err= p) -{ - Object *cpu =3D NULL; - Error *local_err =3D NULL; - CPUX86State *env =3D NULL; - - cpu =3D object_new(MACHINE(pcms)->cpu_type); - - env =3D &X86_CPU(cpu)->env; - env->nr_dies =3D pcms->smp_dies; - - object_property_set_uint(cpu, apic_id, "apic-id", &local_err); - object_property_set_bool(cpu, true, "realized", &local_err); - - object_unref(cpu); - error_propagate(errp, local_err); -} - /* * This function is very similar to smp_parse() * in hw/core/machine.c but includes CPU die support. @@ -1501,32 +1006,6 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t = id, Error **errp) } } =20 -void x86_cpus_init(PCMachineState *pcms) -{ - int i; - const CPUArchIdList *possible_cpus; - MachineState *ms =3D MACHINE(pcms); - MachineClass *mc =3D MACHINE_GET_CLASS(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); - - x86_cpu_set_default_version(pcmc->default_cpu_version); - - /* - * Calculates the limit to CPU APIC ID values - * - * Limit for the APIC ID value, so that all - * CPU APIC IDs are < pcms->apic_id_limit. - * - * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_creat= e(). - */ - pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, - ms->smp.max_cpus - 1)= + 1; - possible_cpus =3D mc->possible_cpu_arch_ids(ms); - for (i =3D 0; i < ms->smp.cpus; i++) { - x86_cpu_new(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); - } -} - static void rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count) { if (cpus_count > 0xff) { @@ -2685,70 +2164,6 @@ static void pc_machine_wakeup(MachineState *machine) cpu_synchronize_all_post_reset(); } =20 -static CpuInstanceProperties -x86_cpu_index_to_props(MachineState *ms, unsigned cpu_index) -{ - MachineClass *mc =3D MACHINE_GET_CLASS(ms); - const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(ms); - - assert(cpu_index < possible_cpus->len); - return possible_cpus->cpus[cpu_index].props; -} - -static int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) -{ - X86CPUTopoInfo topo; - PCMachineState *pcms =3D PC_MACHINE(ms); - - assert(idx < ms->possible_cpus->len); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - pcms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo); - return topo.pkg_id % ms->numa_state->num_nodes; -} - -static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) -{ - PCMachineState *pcms =3D PC_MACHINE(ms); - int i; - unsigned int max_cpus =3D ms->smp.max_cpus; - - if (ms->possible_cpus) { - /* - * make sure that max_cpus hasn't changed since the first use, i.e. - * -smp hasn't been parsed after it - */ - assert(ms->possible_cpus->len =3D=3D max_cpus); - return ms->possible_cpus; - } - - ms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + - sizeof(CPUArchId) * max_cpus); - ms->possible_cpus->len =3D max_cpus; - for (i =3D 0; i < ms->possible_cpus->len; i++) { - X86CPUTopoInfo topo; - - ms->possible_cpus->cpus[i].type =3D ms->cpu_type; - ms->possible_cpus->cpus[i].vcpus_count =3D 1; - ms->possible_cpus->cpus[i].arch_id =3D - x86_cpu_apic_id_from_index(pcms, i); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - pcms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo); - ms->possible_cpus->cpus[i].props.has_socket_id =3D true; - ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; - if (pcms->smp_dies > 1) { - ms->possible_cpus->cpus[i].props.has_die_id =3D true; - ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; - } - ms->possible_cpus->cpus[i].props.has_core_id =3D true; - ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; - ms->possible_cpus->cpus[i].props.has_thread_id =3D true; - ms->possible_cpus->cpus[i].props.thread_id =3D topo.smt_id; - } - return ms->possible_cpus; -} - static void x86_nmi(NMIState *n, int cpu_index, Error **errp) { /* cpu index isn't used */ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index de09e07..1396451 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -27,6 +27,7 @@ =20 #include "qemu/units.h" #include "hw/loader.h" +#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "hw/i386/apic.h" #include "hw/display/ramfb.h" diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 894989b..8920bd8 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -41,6 +41,7 @@ #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h" #include "exec/address-spaces.h" +#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" #include "hw/i386/amd_iommu.h" diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 28cb1f6..f5f3f46 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -31,6 +31,7 @@ #include "qemu/option.h" #include "qemu/units.h" #include "hw/sysbus.h" +#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "hw/loader.h" #include "hw/qdev-properties.h" @@ -38,8 +39,6 @@ #include "hw/block/flash.h" #include "sysemu/kvm.h" =20 -#define BIOS_FILENAME "bios.bin" - /* * We don't have a theoretically justifiable exact lower bound on the base * address of any flash mapping. In practice, the IO-APIC MMIO range is @@ -211,59 +210,6 @@ static void pc_system_flash_map(PCMachineState *pcms, } } =20 -static void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) -{ - char *filename; - MemoryRegion *bios, *isa_bios; - int bios_size, isa_bios_size; - int ret; - - /* BIOS load */ - if (bios_name =3D=3D NULL) { - bios_name =3D BIOS_FILENAME; - } - filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - if (filename) { - bios_size =3D get_image_size(filename); - } else { - bios_size =3D -1; - } - if (bios_size <=3D 0 || - (bios_size % 65536) !=3D 0) { - goto bios_error; - } - bios =3D g_malloc(sizeof(*bios)); - memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal); - if (!isapc_ram_fw) { - memory_region_set_readonly(bios, true); - } - ret =3D rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); - if (ret !=3D 0) { - bios_error: - fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); - exit(1); - } - g_free(filename); - - /* map the last 128KB of the BIOS in ISA space */ - isa_bios_size =3D MIN(bios_size, 128 * KiB); - isa_bios =3D g_malloc(sizeof(*isa_bios)); - memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, - bios_size - isa_bios_size, isa_bios_size); - memory_region_add_subregion_overlap(rom_memory, - 0x100000 - isa_bios_size, - isa_bios, - 1); - if (!isapc_ram_fw) { - memory_region_set_readonly(isa_bios, true); - } - - /* map all the bios at the top of memory */ - memory_region_add_subregion(rom_memory, - (uint32_t)(-bios_size), - bios); -} - void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c new file mode 100644 index 0000000..71fb093 --- /dev/null +++ b/hw/i386/x86.c @@ -0,0 +1,690 @@ +/* + * Copyright (c) 2003-2004 Fabrice Bellard + * Copyright (c) 2019 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * 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 OT= HER + * 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 "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/cutils.h" +#include "qemu/units.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qapi-visit-common.h" +#include "qapi/visitor.h" +#include "sysemu/qtest.h" +#include "sysemu/numa.h" +#include "sysemu/replay.h" +#include "sysemu/sysemu.h" + +#include "hw/i386/x86.h" +#include "hw/i386/pc.h" +#include "target/i386/cpu.h" +#include "hw/i386/topology.h" +#include "hw/i386/fw_cfg.h" + +#include "hw/acpi/cpu_hotplug.h" +#include "hw/nmi.h" +#include "hw/loader.h" +#include "multiboot.h" +#include "elf.h" +#include "standard-headers/asm-x86/bootparam.h" + +#define BIOS_FILENAME "bios.bin" + +/* Physical Address of PVH entry point read from kernel ELF NOTE */ +static size_t pvh_start_addr; + +/* + * Calculates initial APIC ID for a specific CPU index + * + * Currently we need to be able to calculate the APIC ID from the CPU index + * alone (without requiring a CPU object), as the QEMU<->Seabios interface= s have + * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC = ID of + * all CPUs up to max_cpus. + */ +uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, + unsigned int cpu_index) +{ + MachineState *ms =3D MACHINE(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + uint32_t correct_id; + static bool warned; + + correct_id =3D x86_apicid_from_cpu_idx(pcms->smp_dies, ms->smp.cores, + ms->smp.threads, cpu_index); + if (pcmc->compat_apic_id_mode) { + if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { + error_report("APIC IDs set in compatibility mode, " + "CPU topology won't match the configuration"); + warned =3D true; + } + return cpu_index; + } else { + return correct_id; + } +} + +void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **errp) +{ + Object *cpu =3D NULL; + Error *local_err =3D NULL; + CPUX86State *env =3D NULL; + + cpu =3D object_new(MACHINE(pcms)->cpu_type); + + env =3D &X86_CPU(cpu)->env; + env->nr_dies =3D pcms->smp_dies; + + object_property_set_uint(cpu, apic_id, "apic-id", &local_err); + object_property_set_bool(cpu, true, "realized", &local_err); + + object_unref(cpu); + error_propagate(errp, local_err); +} + +void x86_cpus_init(PCMachineState *pcms) +{ + int i; + const CPUArchIdList *possible_cpus; + MachineState *ms =3D MACHINE(pcms); + MachineClass *mc =3D MACHINE_GET_CLASS(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); + + x86_cpu_set_default_version(pcmc->default_cpu_version); + + /* + * Calculates the limit to CPU APIC ID values + * + * Limit for the APIC ID value, so that all + * CPU APIC IDs are < pcms->apic_id_limit. + * + * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_creat= e(). + */ + pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, + ms->smp.max_cpus - 1)= + 1; + possible_cpus =3D mc->possible_cpu_arch_ids(ms); + for (i =3D 0; i < ms->smp.cpus; i++) { + x86_cpu_new(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); + } +} + +CpuInstanceProperties +x86_cpu_index_to_props(MachineState *ms, unsigned cpu_index) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + const CPUArchIdList *possible_cpus =3D mc->possible_cpu_arch_ids(ms); + + assert(cpu_index < possible_cpus->len); + return possible_cpus->cpus[cpu_index].props; +} + +int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) +{ + X86CPUTopoInfo topo; + PCMachineState *pcms =3D PC_MACHINE(ms); + + assert(idx < ms->possible_cpus->len); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); + return topo.pkg_id % ms->numa_state->num_nodes; +} + +const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) +{ + PCMachineState *pcms =3D PC_MACHINE(ms); + int i; + unsigned int max_cpus =3D ms->smp.max_cpus; + + if (ms->possible_cpus) { + /* + * make sure that max_cpus hasn't changed since the first use, i.e. + * -smp hasn't been parsed after it + */ + assert(ms->possible_cpus->len =3D=3D max_cpus); + return ms->possible_cpus; + } + + ms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * max_cpus); + ms->possible_cpus->len =3D max_cpus; + for (i =3D 0; i < ms->possible_cpus->len; i++) { + X86CPUTopoInfo topo; + + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; + ms->possible_cpus->cpus[i].vcpus_count =3D 1; + ms->possible_cpus->cpus[i].arch_id =3D + x86_cpu_apic_id_from_index(pcms, i); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); + ms->possible_cpus->cpus[i].props.has_socket_id =3D true; + ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; + if (pcms->smp_dies > 1) { + ms->possible_cpus->cpus[i].props.has_die_id =3D true; + ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; + } + ms->possible_cpus->cpus[i].props.has_core_id =3D true; + ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; + ms->possible_cpus->cpus[i].props.has_thread_id =3D true; + ms->possible_cpus->cpus[i].props.thread_id =3D topo.smt_id; + } + return ms->possible_cpus; +} + +static long get_file_size(FILE *f) +{ + long where, size; + + /* XXX: on Unix systems, using fstat() probably makes more sense */ + + where =3D ftell(f); + fseek(f, 0, SEEK_END); + size =3D ftell(f); + fseek(f, where, SEEK_SET); + + return size; +} + +struct setup_data { + uint64_t next; + uint32_t type; + uint32_t len; + uint8_t data[0]; +} __attribute__((packed)); + + +/* + * The entry point into the kernel for PVH boot is different from + * the native entry point. The PVH entry is defined by the x86/HVM + * direct boot ABI and is available in an ELFNOTE in the kernel binary. + * + * This function is passed to load_elf() when it is called from + * load_elfboot() which then additionally checks for an ELF Note of + * type XEN_ELFNOTE_PHYS32_ENTRY and passes it to this function to + * parse the PVH entry address from the ELF Note. + * + * Due to trickery in elf_opts.h, load_elf() is actually available as + * load_elf32() or load_elf64() and this routine needs to be able + * to deal with being called as 32 or 64 bit. + * + * The address of the PVH entry point is saved to the 'pvh_start_addr' + * global variable. (although the entry point is 32-bit, the kernel + * binary can be either 32-bit or 64-bit). + */ +static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) +{ + size_t *elf_note_data_addr; + + /* Check if ELF Note header passed in is valid */ + if (arg1 =3D=3D NULL) { + return 0; + } + + if (is64) { + struct elf64_note *nhdr64 =3D (struct elf64_note *)arg1; + uint64_t nhdr_size64 =3D sizeof(struct elf64_note); + uint64_t phdr_align =3D *(uint64_t *)arg2; + uint64_t nhdr_namesz =3D nhdr64->n_namesz; + + elf_note_data_addr =3D + ((void *)nhdr64) + nhdr_size64 + + QEMU_ALIGN_UP(nhdr_namesz, phdr_align); + } else { + struct elf32_note *nhdr32 =3D (struct elf32_note *)arg1; + uint32_t nhdr_size32 =3D sizeof(struct elf32_note); + uint32_t phdr_align =3D *(uint32_t *)arg2; + uint32_t nhdr_namesz =3D nhdr32->n_namesz; + + elf_note_data_addr =3D + ((void *)nhdr32) + nhdr_size32 + + QEMU_ALIGN_UP(nhdr_namesz, phdr_align); + } + + pvh_start_addr =3D *elf_note_data_addr; + + return pvh_start_addr; +} + +static bool load_elfboot(const char *kernel_filename, + int kernel_file_size, + uint8_t *header, + size_t pvh_xen_start_addr, + FWCfgState *fw_cfg) +{ + uint32_t flags =3D 0; + uint32_t mh_load_addr =3D 0; + uint32_t elf_kernel_size =3D 0; + uint64_t elf_entry; + uint64_t elf_low, elf_high; + int kernel_size; + + if (ldl_p(header) !=3D 0x464c457f) { + return false; /* no elfboot */ + } + + bool elf_is64 =3D header[EI_CLASS] =3D=3D ELFCLASS64; + flags =3D elf_is64 ? + ((Elf64_Ehdr *)header)->e_flags : ((Elf32_Ehdr *)header)->e_flags; + + if (flags & 0x00010004) { /* LOAD_ELF_HEADER_HAS_ADDR */ + error_report("elfboot unsupported flags =3D %x", flags); + exit(1); + } + + uint64_t elf_note_type =3D XEN_ELFNOTE_PHYS32_ENTRY; + kernel_size =3D load_elf(kernel_filename, read_pvh_start_addr, + NULL, &elf_note_type, &elf_entry, + &elf_low, &elf_high, 0, I386_ELF_MACHINE, + 0, 0); + + if (kernel_size < 0) { + error_report("Error while loading elf kernel"); + exit(1); + } + mh_load_addr =3D elf_low; + elf_kernel_size =3D elf_high - elf_low; + + if (pvh_start_addr =3D=3D 0) { + error_report("Error loading uncompressed kernel without PVH ELF No= te"); + exit(1); + } + fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, pvh_start_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, mh_load_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, elf_kernel_size); + + return true; +} + +void x86_load_linux(PCMachineState *pcms, + FWCfgState *fw_cfg) +{ + uint16_t protocol; + int setup_size, kernel_size, cmdline_size; + int dtb_size, setup_data_offset; + uint32_t initrd_max; + uint8_t header[8192], *setup, *kernel; + hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =3D 0; + FILE *f; + char *vmode; + MachineState *machine =3D MACHINE(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + struct setup_data *setup_data; + const char *kernel_filename =3D machine->kernel_filename; + const char *initrd_filename =3D machine->initrd_filename; + const char *dtb_filename =3D machine->dtb; + const char *kernel_cmdline =3D machine->kernel_cmdline; + + /* Align to 16 bytes as a paranoia measure */ + cmdline_size =3D (strlen(kernel_cmdline) + 16) & ~15; + + /* load the kernel header */ + f =3D fopen(kernel_filename, "rb"); + if (!f) { + fprintf(stderr, "qemu: could not open kernel file '%s': %s\n", + kernel_filename, strerror(errno)); + exit(1); + } + + kernel_size =3D get_file_size(f); + if (!kernel_size || + fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=3D + MIN(ARRAY_SIZE(header), kernel_size)) { + fprintf(stderr, "qemu: could not load kernel '%s': %s\n", + kernel_filename, strerror(errno)); + exit(1); + } + + /* kernel protocol version */ + if (ldl_p(header + 0x202) =3D=3D 0x53726448) { + protocol =3D lduw_p(header + 0x206); + } else { + /* + * This could be a multiboot kernel. If it is, let's stop treating= it + * like a Linux kernel. + * Note: some multiboot images could be in the ELF format (the sam= e of + * PVH), so we try multiboot first since we check the multiboot ma= gic + * header before to load it. + */ + if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, + kernel_cmdline, kernel_size, header)) { + return; + } + /* + * Check if the file is an uncompressed kernel file (ELF) and load= it, + * saving the PVH entry point used by the x86/HVM direct boot ABI. + * If load_elfboot() is successful, populate the fw_cfg info. + */ + if (pcmc->pvh_enabled && + load_elfboot(kernel_filename, kernel_size, + header, pvh_start_addr, fw_cfg)) { + fclose(f); + + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, + strlen(kernel_cmdline) + 1); + fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); + + fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, sizeof(header)); + fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, + header, sizeof(header)); + + /* load initrd */ + if (initrd_filename) { + GMappedFile *mapped_file; + gsize initrd_size; + gchar *initrd_data; + GError *gerr =3D NULL; + + mapped_file =3D g_mapped_file_new(initrd_filename, false, = &gerr); + if (!mapped_file) { + fprintf(stderr, "qemu: error reading initrd %s: %s\n", + initrd_filename, gerr->message); + exit(1); + } + pcms->initrd_mapped_file =3D mapped_file; + + initrd_data =3D g_mapped_file_get_contents(mapped_file); + initrd_size =3D g_mapped_file_get_length(mapped_file); + initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_s= ize - 1; + if (initrd_size >=3D initrd_max) { + fprintf(stderr, "qemu: initrd is too large, cannot sup= port." + "(max: %"PRIu32", need %"PRId64")\n", + initrd_max, (uint64_t)initrd_size); + exit(1); + } + + initrd_addr =3D (initrd_max - initrd_size) & ~4095; + + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, + initrd_size); + } + + option_rom[nb_option_roms].bootindex =3D 0; + option_rom[nb_option_roms].name =3D "pvh.bin"; + nb_option_roms++; + + return; + } + protocol =3D 0; + } + + if (protocol < 0x200 || !(header[0x211] & 0x01)) { + /* Low kernel */ + real_addr =3D 0x90000; + cmdline_addr =3D 0x9a000 - cmdline_size; + prot_addr =3D 0x10000; + } else if (protocol < 0x202) { + /* High but ancient kernel */ + real_addr =3D 0x90000; + cmdline_addr =3D 0x9a000 - cmdline_size; + prot_addr =3D 0x100000; + } else { + /* High and recent kernel */ + real_addr =3D 0x10000; + cmdline_addr =3D 0x20000; + prot_addr =3D 0x100000; + } + + /* highest address for loading the initrd */ + if (protocol >=3D 0x20c && + lduw_p(header + 0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) { + /* + * Linux has supported initrd up to 4 GB for a very long time (200= 7, + * long before XLF_CAN_BE_LOADED_ABOVE_4G which was added in 2013), + * though it only sets initrd_max to 2 GB to "work around bootload= er + * bugs". Luckily, QEMU firmware(which does something like bootloa= der) + * has supported this. + * + * It's believed that if XLF_CAN_BE_LOADED_ABOVE_4G is set, initrd= can + * be loaded into any address. + * + * In addition, initrd_max is uint32_t simply because QEMU doesn't + * support the 64-bit boot protocol (specifically the ext_ramdisk_= image + * field). + * + * Therefore here just limit initrd_max to UINT32_MAX simply as we= ll. + */ + initrd_max =3D UINT32_MAX; + } else if (protocol >=3D 0x203) { + initrd_max =3D ldl_p(header + 0x22c); + } else { + initrd_max =3D 0x37ffffff; + } + + if (initrd_max >=3D pcms->below_4g_mem_size - pcmc->acpi_data_size) { + initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_size - 1; + } + + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1= ); + fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); + + if (protocol >=3D 0x202) { + stl_p(header + 0x228, cmdline_addr); + } else { + stw_p(header + 0x20, 0xA33F); + stw_p(header + 0x22, cmdline_addr - real_addr); + } + + /* handle vga=3D parameter */ + vmode =3D strstr(kernel_cmdline, "vga=3D"); + if (vmode) { + unsigned int video_mode; + int ret; + /* skip "vga=3D" */ + vmode +=3D 4; + if (!strncmp(vmode, "normal", 6)) { + video_mode =3D 0xffff; + } else if (!strncmp(vmode, "ext", 3)) { + video_mode =3D 0xfffe; + } else if (!strncmp(vmode, "ask", 3)) { + video_mode =3D 0xfffd; + } else { + ret =3D qemu_strtoui(vmode, NULL, 0, &video_mode); + if (ret !=3D 0) { + fprintf(stderr, "qemu: can't parse 'vga' parameter: %s\n", + strerror(-ret)); + exit(1); + } + } + stw_p(header + 0x1fa, video_mode); + } + + /* loader type */ + /* + * High nybble =3D B reserved for QEMU; low nybble is revision number. + * If this code is substantially changed, you may want to consider + * incrementing the revision. + */ + if (protocol >=3D 0x200) { + header[0x210] =3D 0xB0; + } + /* heap */ + if (protocol >=3D 0x201) { + header[0x211] |=3D 0x80; /* CAN_USE_HEAP */ + stw_p(header + 0x224, cmdline_addr - real_addr - 0x200); + } + + /* load initrd */ + if (initrd_filename) { + GMappedFile *mapped_file; + gsize initrd_size; + gchar *initrd_data; + GError *gerr =3D NULL; + + if (protocol < 0x200) { + fprintf(stderr, "qemu: linux kernel too old to load a ram disk= \n"); + exit(1); + } + + mapped_file =3D g_mapped_file_new(initrd_filename, false, &gerr); + if (!mapped_file) { + fprintf(stderr, "qemu: error reading initrd %s: %s\n", + initrd_filename, gerr->message); + exit(1); + } + pcms->initrd_mapped_file =3D mapped_file; + + initrd_data =3D g_mapped_file_get_contents(mapped_file); + initrd_size =3D g_mapped_file_get_length(mapped_file); + if (initrd_size >=3D initrd_max) { + fprintf(stderr, "qemu: initrd is too large, cannot support." + "(max: %"PRIu32", need %"PRId64")\n", + initrd_max, (uint64_t)initrd_size); + exit(1); + } + + initrd_addr =3D (initrd_max - initrd_size) & ~4095; + + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_s= ize); + + stl_p(header + 0x218, initrd_addr); + stl_p(header + 0x21c, initrd_size); + } + + /* load kernel and setup */ + setup_size =3D header[0x1f1]; + if (setup_size =3D=3D 0) { + setup_size =3D 4; + } + setup_size =3D (setup_size + 1) * 512; + if (setup_size > kernel_size) { + fprintf(stderr, "qemu: invalid kernel header\n"); + exit(1); + } + kernel_size -=3D setup_size; + + setup =3D g_malloc(setup_size); + kernel =3D g_malloc(kernel_size); + fseek(f, 0, SEEK_SET); + if (fread(setup, 1, setup_size, f) !=3D setup_size) { + fprintf(stderr, "fread() failed\n"); + exit(1); + } + if (fread(kernel, 1, kernel_size, f) !=3D kernel_size) { + fprintf(stderr, "fread() failed\n"); + exit(1); + } + fclose(f); + + /* append dtb to kernel */ + if (dtb_filename) { + if (protocol < 0x209) { + fprintf(stderr, "qemu: Linux kernel too old to load a dtb\n"); + exit(1); + } + + dtb_size =3D get_image_size(dtb_filename); + if (dtb_size <=3D 0) { + fprintf(stderr, "qemu: error reading dtb %s: %s\n", + dtb_filename, strerror(errno)); + exit(1); + } + + setup_data_offset =3D QEMU_ALIGN_UP(kernel_size, 16); + kernel_size =3D setup_data_offset + sizeof(struct setup_data) + dt= b_size; + kernel =3D g_realloc(kernel, kernel_size); + + stq_p(header + 0x250, prot_addr + setup_data_offset); + + setup_data =3D (struct setup_data *)(kernel + setup_data_offset); + setup_data->next =3D 0; + setup_data->type =3D cpu_to_le32(SETUP_DTB); + setup_data->len =3D cpu_to_le32(dtb_size); + + load_image_size(dtb_filename, setup_data->data, dtb_size); + } + + memcpy(setup, header, MIN(sizeof(header), setup_size)); + + fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size); + + fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size); + + option_rom[nb_option_roms].bootindex =3D 0; + option_rom[nb_option_roms].name =3D "linuxboot.bin"; + if (pcmc->linuxboot_dma_enabled && fw_cfg_dma_enabled(fw_cfg)) { + option_rom[nb_option_roms].name =3D "linuxboot_dma.bin"; + } + nb_option_roms++; +} + +void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) +{ + char *filename; + MemoryRegion *bios, *isa_bios; + int bios_size, isa_bios_size; + int ret; + + /* BIOS load */ + if (bios_name =3D=3D NULL) { + bios_name =3D BIOS_FILENAME; + } + filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size =3D get_image_size(filename); + } else { + bios_size =3D -1; + } + if (bios_size <=3D 0 || + (bios_size % 65536) !=3D 0) { + goto bios_error; + } + bios =3D g_malloc(sizeof(*bios)); + memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal); + if (!isapc_ram_fw) { + memory_region_set_readonly(bios, true); + } + ret =3D rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); + if (ret !=3D 0) { + bios_error: + fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); + exit(1); + } + g_free(filename); + + /* map the last 128KB of the BIOS in ISA space */ + isa_bios_size =3D MIN(bios_size, 128 * KiB); + isa_bios =3D g_malloc(sizeof(*isa_bios)); + memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, + bios_size - isa_bios_size, isa_bios_size); + memory_region_add_subregion_overlap(rom_memory, + 0x100000 - isa_bios_size, + isa_bios, + 1); + if (!isapc_ram_fw) { + memory_region_set_readonly(isa_bios, true); + } + + /* map all the bios at the top of memory */ + memory_region_add_subregion(rom_memory, + (uint32_t)(-bios_size), + bios); +} diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 7082b06..f135ae8 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -198,7 +198,6 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms); void pc_register_ferr_irq(qemu_irq irq); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); =20 -void x86_cpus_init(PCMachineState *pcms); void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp); void pc_smp_parse(MachineState *ms, QemuOpts *opts); =20 diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h new file mode 100644 index 0000000..71e2b69 --- /dev/null +++ b/include/hw/i386/x86.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#ifndef HW_I386_X86_H +#define HW_I386_X86_H + +#include "hw/boards.h" + +uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, + unsigned int cpu_index); +void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **errp); +void x86_cpus_init(PCMachineState *pcms); +CpuInstanceProperties x86_cpu_index_to_props(MachineState *ms, + unsigned cpu_index); +int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx); +const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms); + +void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw); + +void x86_load_linux(PCMachineState *x86ms, FWCfgState *fw_cfg); + +#endif --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928955; cv=none; d=zoho.com; s=zohoarc; b=TWYqTIBj0sm9lMRcyMeh6K2fwGtxsGssne5/Bo+CEJvTjLN52onqa9s7CYvhON5/TQJm8M2vbKeSPdvbmRcfjw0rNQ0MRU94gYyiCjH3QKSh3VubLSxLmxdZdjEzgiN8yDzcpFBrAMIrJhevIY5AINLbw931se0NDm+b06WzcNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928955; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9ccuGquyvu+pMYDj2Caw3rtJDYChmE+/auv7h93x5vY=; b=U+rnKfjpR8uRKc61IX0Mlx/p7u5OqGjf57MOp2xUJxtwzp7dSiMbnU4QVp0fYn8otP2FRGrZjV9hw4RSUGwuVbb8hzj1ItDhgwuErq4ujF8jQZzcYZpRYlI00Y0gnjyRKPz6i4jdTtUIpVoIcPjpzZBb+XkU1cJeWBa+P8R7qhc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928955766496.69771546440086; Thu, 24 Oct 2019 07:55:55 -0700 (PDT) Received: from localhost ([::1]:44758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeWo-0004Z0-7t for importer@patchew.org; Thu, 24 Oct 2019 10:55:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34826) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiy-0007rz-Lr for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdit-0007ib-AW for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdir-0007hK-6y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:17 -0400 Received: by mail-wr1-x42e.google.com with SMTP id p4so26246056wrm.8 for ; Thu, 24 Oct 2019 07:04:16 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ccuGquyvu+pMYDj2Caw3rtJDYChmE+/auv7h93x5vY=; b=bKubpUJphpZfDjYQFrqDqmixDiAVXh3yW5A9YvnE0TRr5+5CL8w5++Mzi47BfYET4i 94z3QIpEcsslxqafrTFDJIDUuxQCDE8ewnhH2QiXXyMO3k+127AuEuX/IbrA6xxoPA+D 6JG1qOBFyRHcqOAETmTk7JyvF50unP6Ed1uP7PEWSIsCGwVvdT8IYuakrRKvCCV682FX q59UxQfutUkcIcCPSmyUl+nHB76Db5nNxymfFs1YH81jP/eLMXdC+QauNuqHrLrq0WPN u4e6ZDl8zCHhNeYvNctm09bNW7qRrtIbe1fj8D7CNYRPkKwCRAkqTDDyouXOFblt6ofu T39Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9ccuGquyvu+pMYDj2Caw3rtJDYChmE+/auv7h93x5vY=; b=bBIcqWXbY5s4MJV5IkqfZ4jsJsNmDFR7Dq0N0cAITloWyZOdvkoLuBfyPgKwN59gLc XJyWS4gIUMerfyKixX0cE3EWtQxKpTL5k8QYk/QRj7mLTmshW8aBdjfPW0cjFuwyn3ig PazCaghF03JPak+0jIlhvzXdyDy8Twr6VgxHh51/ClYafbUjTOytp7kK9cmn5LZXNanv dfV2aIgdD0uOKBok5PIOOjArBjxnAUS9jLBkuJrY6G9Ls/6JC9+6hLUKAOdGUVY6zl7K rEco4QsZRusf/QFgy7/yWPOcEtigSGCOmGiySAEFmEhU2i+n1Amw8uPq8CiFENrdkuxe rDbA== X-Gm-Message-State: APjAAAWsR3WSD6rtSqymQPLOCSL3QVPH0w4OSQx3fABl21CvvfeqLsve fFxmCHDtD/0fjjJc3hSSvR//4RiZ X-Google-Smtp-Source: APXvYqx5AZGurfO5tD2oOjEF8MuJq3aqgyv5tHwUEI59DrKz+a9P0lpru9ZZw7TV67VG6sO9BR4Ppw== X-Received: by 2002:a5d:62c5:: with SMTP id o5mr4386152wrv.388.1571925853766; Thu, 24 Oct 2019 07:04:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/39] hw/i386: split PCMachineState deriving X86MachineState from it Date: Thu, 24 Oct 2019 16:03:30 +0200 Message-Id: <1571925835-31930-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Split up PCMachineState and PCMachineClass and derive X86MachineState and X86MachineClass from them. This allows sharing code with non-PC x86 machine types. Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- hw/acpi/cpu_hotplug.c | 10 +-- hw/i386/acpi-build.c | 29 ++++---- hw/i386/amd_iommu.c | 3 +- hw/i386/intel_iommu.c | 3 +- hw/i386/pc.c | 178 +++++++++++++++++-----------------------------= ---- hw/i386/pc_piix.c | 43 ++++++------ hw/i386/pc_q35.c | 35 +++++----- hw/i386/x86.c | 140 ++++++++++++++++++++++++++++++++++----- hw/i386/xen/xen-hvm.c | 28 ++++---- hw/intc/ioapic.c | 2 +- include/hw/i386/pc.h | 27 +------- include/hw/i386/x86.h | 58 +++++++++++++++- 12 files changed, 326 insertions(+), 230 deletions(-) diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 6e8293a..3ac2045 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -128,7 +128,7 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineStat= e *machine, Aml *one =3D aml_int(1); MachineClass *mc =3D MACHINE_GET_CLASS(machine); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(machine); - PCMachineState *pcms =3D PC_MACHINE(machine); + X86MachineState *x86ms =3D X86_MACHINE(machine); =20 /* * _MAT method - creates an madt apic buffer @@ -236,9 +236,9 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineStat= e *machine, /* The current AML generator can cover the APIC ID range [0..255], * inclusive, for VCPU hotplug. */ QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); - if (pcms->apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) { + if (x86ms->apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) { error_report("max_cpus is too large. APIC ID of last CPU is %u", - pcms->apic_id_limit - 1); + x86ms->apic_id_limit - 1); exit(1); } =20 @@ -315,8 +315,8 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineStat= e *machine, * ith up to 255 elements. Windows guests up to win2k8 fail when * VarPackageOp is used. */ - pkg =3D pcms->apic_id_limit <=3D 255 ? aml_package(pcms->apic_id_limit= ) : - aml_varpackage(pcms->apic_id_limit); + pkg =3D x86ms->apic_id_limit <=3D 255 ? aml_package(x86ms->apic_id_lim= it) : + aml_varpackage(x86ms->apic_id_limi= t); =20 for (i =3D 0, apic_idx =3D 0; i < apic_ids->len; i++) { int apic_id =3D apic_ids->cpus[i].arch_id; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1d077a7..bc0256e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -361,6 +361,7 @@ static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) { MachineClass *mc =3D MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); int madt_start =3D table_data->len; AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); @@ -390,7 +391,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMa= chineState *pcms) io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); io_apic->interrupt =3D cpu_to_le32(0); =20 - if (pcms->apic_xrupt_override) { + if (x86ms->apic_xrupt_override) { intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; intsrcovr->length =3D sizeof(*intsrcovr); @@ -1831,6 +1832,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, CrsRangeSet crs_range_set; PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(machine); + X86MachineState *x86ms =3D X86_MACHINE(machine); AcpiMcfgInfo mcfg; uint32_t nr_mem =3D machine->ram_slots; int root_bus_limit =3D 0xFF; @@ -2103,7 +2105,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, * with half of the 16-bit control register. Hence, the total size * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */ - uint8_t io_size =3D object_property_get_bool(OBJECT(pcms->fw_cfg), + uint8_t io_size =3D object_property_get_bool(OBJECT(x86ms->fw_cfg), "dma_enabled", NULL) ? ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t= ) : FW_CFG_CTL_SIZE; @@ -2336,6 +2338,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) int srat_start, numa_start, slots; uint64_t mem_len, mem_base, next_base; MachineClass *mc =3D MACHINE_GET_CLASS(machine); + X86MachineState *x86ms =3D X86_MACHINE(machine); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(machine); PCMachineState *pcms =3D PC_MACHINE(machine); ram_addr_t hotplugabble_address_space_size =3D @@ -2406,16 +2409,16 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) } =20 /* Cut out the ACPI_PCI hole */ - if (mem_base <=3D pcms->below_4g_mem_size && - next_base > pcms->below_4g_mem_size) { - mem_len -=3D next_base - pcms->below_4g_mem_size; + if (mem_base <=3D x86ms->below_4g_mem_size && + next_base > x86ms->below_4g_mem_size) { + mem_len -=3D next_base - x86ms->below_4g_mem_size; if (mem_len > 0) { numamem =3D acpi_data_push(table_data, sizeof *numamem); build_srat_memory(numamem, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } mem_base =3D 1ULL << 32; - mem_len =3D next_base - pcms->below_4g_mem_size; + mem_len =3D next_base - x86ms->below_4g_mem_size; next_base =3D mem_base + mem_len; } =20 @@ -2634,6 +2637,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) { PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(machine); GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; @@ -2795,7 +2799,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) */ int legacy_aml_len =3D pcmc->legacy_acpi_table_size + - ACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit; + ACPI_BUILD_LEGACY_CPU_AML_SIZE * x86ms->apic_id_limit; int legacy_table_size =3D ROUND_UP(tables_blob->len - aml_len + legacy_aml_len, ACPI_BUILD_ALIGN_SIZE); @@ -2885,13 +2889,14 @@ void acpi_setup(void) { PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); AcpiBuildTables tables; AcpiBuildState *build_state; Object *vmgenid_dev; TPMIf *tpm; static FwCfgTPMConfig tpm_config; =20 - if (!pcms->fw_cfg) { + if (!x86ms->fw_cfg) { ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); return; } @@ -2922,7 +2927,7 @@ void acpi_setup(void) acpi_add_rom_blob(acpi_build_update, build_state, tables.linker->cmd_blob, "etc/table-loader", 0); =20 - fw_cfg_add_file(pcms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, + fw_cfg_add_file(x86ms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); =20 tpm =3D tpm_find(); @@ -2932,13 +2937,13 @@ void acpi_setup(void) .tpm_version =3D tpm_get_version(tpm), .tpmppi_version =3D TPM_PPI_VERSION_1_30 }; - fw_cfg_add_file(pcms->fw_cfg, "etc/tpm/config", + fw_cfg_add_file(x86ms->fw_cfg, "etc/tpm/config", &tpm_config, sizeof tpm_config); } =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { - vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), pcms->fw_cfg, + vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), x86ms->fw_cfg, tables.vmgenid); } =20 @@ -2951,7 +2956,7 @@ void acpi_setup(void) uint32_t rsdp_size =3D acpi_data_len(tables.rsdp); =20 build_state->rsdp =3D g_memdup(tables.rsdp->data, rsdp_size); - fw_cfg_add_file_callback(pcms->fw_cfg, ACPI_BUILD_RSDP_FILE, + fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE, acpi_build_update, NULL, build_state, build_state->rsdp, rsdp_size, true); build_state->rsdp_mr =3D NULL; diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index d372636..d55dbf0 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1540,6 +1540,7 @@ static void amdvi_realize(DeviceState *dev, Error **e= rr) X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); MachineState *ms =3D MACHINE(qdev_get_machine()); PCMachineState *pcms =3D PC_MACHINE(ms); + X86MachineState *x86ms =3D X86_MACHINE(ms); PCIBus *bus =3D pcms->bus; =20 s->iotlb =3D g_hash_table_new_full(amdvi_uint64_hash, @@ -1568,7 +1569,7 @@ static void amdvi_realize(DeviceState *dev, Error **e= rr) } =20 /* Pseudo address space under root PCI bus. */ - pcms->ioapic_as =3D amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID= ); + x86ms->ioapic_as =3D amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVI= D); =20 /* set up MMIO */ memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mm= io", diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 771bed2..14e4e6a 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3733,6 +3733,7 @@ static void vtd_realize(DeviceState *dev, Error **err= p) { MachineState *ms =3D MACHINE(qdev_get_machine()); PCMachineState *pcms =3D PC_MACHINE(ms); + X86MachineState *x86ms =3D X86_MACHINE(ms); PCIBus *bus =3D pcms->bus; IntelIOMMUState *s =3D INTEL_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(dev); @@ -3773,7 +3774,7 @@ static void vtd_realize(DeviceState *dev, Error **err= p) sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR); pci_setup_iommu(bus, vtd_host_dma_iommu, dev); /* Pseudo address space under root PCI bus. */ - pcms->ioapic_as =3D vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC= ); + x86ms->ioapic_as =3D vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPI= C); qemu_add_machine_init_done_notifier(&vtd_machine_done_notify); } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4a1bc95..e6ad1f1 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -79,7 +79,6 @@ #include "qapi/qapi-visit-common.h" #include "qapi/visitor.h" #include "hw/core/cpu.h" -#include "hw/nmi.h" #include "hw/usb.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" @@ -680,17 +679,18 @@ void pc_cmos_init(PCMachineState *pcms, { int val; static pc_cmos_init_late_arg arg; + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 /* various important CMOS locations needed by PC/Bochs bios */ =20 /* memory size */ /* base memory (first MiB) */ - val =3D MIN(pcms->below_4g_mem_size / KiB, 640); + val =3D MIN(x86ms->below_4g_mem_size / KiB, 640); rtc_set_memory(s, 0x15, val); rtc_set_memory(s, 0x16, val >> 8); /* extended memory (next 64MiB) */ - if (pcms->below_4g_mem_size > 1 * MiB) { - val =3D (pcms->below_4g_mem_size - 1 * MiB) / KiB; + if (x86ms->below_4g_mem_size > 1 * MiB) { + val =3D (x86ms->below_4g_mem_size - 1 * MiB) / KiB; } else { val =3D 0; } @@ -701,8 +701,8 @@ void pc_cmos_init(PCMachineState *pcms, rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); /* memory between 16MiB and 4GiB */ - if (pcms->below_4g_mem_size > 16 * MiB) { - val =3D (pcms->below_4g_mem_size - 16 * MiB) / (64 * KiB); + if (x86ms->below_4g_mem_size > 16 * MiB) { + val =3D (x86ms->below_4g_mem_size - 16 * MiB) / (64 * KiB); } else { val =3D 0; } @@ -711,14 +711,14 @@ void pc_cmos_init(PCMachineState *pcms, rtc_set_memory(s, 0x34, val); rtc_set_memory(s, 0x35, val >> 8); /* memory above 4GiB */ - val =3D pcms->above_4g_mem_size / 65536; + val =3D x86ms->above_4g_mem_size / 65536; rtc_set_memory(s, 0x5b, val); rtc_set_memory(s, 0x5c, val >> 8); rtc_set_memory(s, 0x5d, val >> 16); =20 object_property_add_link(OBJECT(pcms), "rtc_state", TYPE_ISA_DEVICE, - (Object **)&pcms->rtc, + (Object **)&x86ms->rtc, object_property_allow_set_link, OBJ_PROP_LINK_STRONG, &error_abort); object_property_set_link(OBJECT(pcms), OBJECT(s), @@ -907,7 +907,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int l= evel) */ void pc_smp_parse(MachineState *ms, QemuOpts *opts) { - PCMachineState *pcms =3D PC_MACHINE(ms); + X86MachineState *x86ms =3D X86_MACHINE(ms); =20 if (opts) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); @@ -971,7 +971,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; - pcms->smp_dies =3D dies; + x86ms->smp_dies =3D dies; } =20 if (ms->smp.cpus > 1) { @@ -1024,10 +1024,11 @@ void pc_machine_done(Notifier *notifier, void *data) { PCMachineState *pcms =3D container_of(notifier, PCMachineState, machine_done); + X86MachineState *x86ms =3D X86_MACHINE(pcms); PCIBus *bus =3D pcms->bus; =20 /* set the number of CPUs */ - rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus); + rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus); =20 if (bus) { int extra_hosts =3D 0; @@ -1038,23 +1039,23 @@ void pc_machine_done(Notifier *notifier, void *data) extra_hosts++; } } - if (extra_hosts && pcms->fw_cfg) { + if (extra_hosts && x86ms->fw_cfg) { uint64_t *val =3D g_malloc(sizeof(*val)); *val =3D cpu_to_le64(extra_hosts); - fw_cfg_add_file(pcms->fw_cfg, + fw_cfg_add_file(x86ms->fw_cfg, "etc/extra-pci-roots", val, sizeof(*val)); } } =20 acpi_setup(); - if (pcms->fw_cfg) { - fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg); - fw_cfg_build_feature_control(MACHINE(pcms), pcms->fw_cfg); + if (x86ms->fw_cfg) { + fw_cfg_build_smbios(MACHINE(pcms), x86ms->fw_cfg); + fw_cfg_build_feature_control(MACHINE(pcms), x86ms->fw_cfg); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ - fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); } =20 - if (pcms->apic_id_limit > 255 && !xen_enabled()) { + if (x86ms->apic_id_limit > 255 && !xen_enabled()) { IntelIOMMUState *iommu =3D INTEL_IOMMU_DEVICE(x86_iommu_get_defaul= t()); =20 if (!iommu || !x86_iommu_ir_supported(X86_IOMMU_DEVICE(iommu)) || @@ -1072,8 +1073,9 @@ void pc_guest_info_init(PCMachineState *pcms) { int i; MachineState *ms =3D MACHINE(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 - pcms->apic_xrupt_override =3D kvm_allows_irq0_override(); + x86ms->apic_xrupt_override =3D kvm_allows_irq0_override(); pcms->numa_nodes =3D ms->numa_state->num_nodes; pcms->node_mem =3D g_malloc0(pcms->numa_nodes * sizeof *pcms->node_mem); @@ -1098,11 +1100,12 @@ void xen_load_linux(PCMachineState *pcms) { int i; FWCfgState *fw_cfg; + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 assert(MACHINE(pcms)->kernel_filename !=3D NULL); =20 fw_cfg =3D fw_cfg_init_io(FW_CFG_IO_BASE); - fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); rom_set_fw(fw_cfg); =20 x86_load_linux(pcms, fw_cfg); @@ -1113,7 +1116,7 @@ void xen_load_linux(PCMachineState *pcms) !strcmp(option_rom[i].name, "multiboot.bin")); rom_add_option(option_rom[i].name, option_rom[i].bootindex); } - pcms->fw_cfg =3D fw_cfg; + x86ms->fw_cfg =3D fw_cfg; } =20 void pc_memory_init(PCMachineState *pcms, @@ -1128,9 +1131,10 @@ void pc_memory_init(PCMachineState *pcms, MachineState *machine =3D MACHINE(pcms); MachineClass *mc =3D MACHINE_GET_CLASS(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 - assert(machine->ram_size =3D=3D pcms->below_4g_mem_size + - pcms->above_4g_mem_size); + assert(machine->ram_size =3D=3D x86ms->below_4g_mem_size + + x86ms->above_4g_mem_size); =20 linux_boot =3D (machine->kernel_filename !=3D NULL); =20 @@ -1144,17 +1148,17 @@ void pc_memory_init(PCMachineState *pcms, *ram_memory =3D ram; ram_below_4g =3D g_malloc(sizeof(*ram_below_4g)); memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, - 0, pcms->below_4g_mem_size); + 0, x86ms->below_4g_mem_size); memory_region_add_subregion(system_memory, 0, ram_below_4g); - e820_add_entry(0, pcms->below_4g_mem_size, E820_RAM); - if (pcms->above_4g_mem_size > 0) { + e820_add_entry(0, x86ms->below_4g_mem_size, E820_RAM); + if (x86ms->above_4g_mem_size > 0) { ram_above_4g =3D g_malloc(sizeof(*ram_above_4g)); memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, - pcms->below_4g_mem_size, - pcms->above_4g_mem_size); + x86ms->below_4g_mem_size, + x86ms->above_4g_mem_size); memory_region_add_subregion(system_memory, 0x100000000ULL, ram_above_4g); - e820_add_entry(0x100000000ULL, pcms->above_4g_mem_size, E820_RAM); + e820_add_entry(0x100000000ULL, x86ms->above_4g_mem_size, E820_RAM); } =20 if (!pcmc->has_reserved_memory && @@ -1188,7 +1192,7 @@ void pc_memory_init(PCMachineState *pcms, } =20 machine->device_memory->base =3D - ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1 * GiB); + ROUND_UP(0x100000000ULL + x86ms->above_4g_mem_size, 1 * GiB); =20 if (pcmc->enforce_aligned_dimm) { /* size device region assuming 1G page max alignment per slot = */ @@ -1223,7 +1227,7 @@ void pc_memory_init(PCMachineState *pcms, 1); =20 fw_cfg =3D fw_cfg_arch_create(machine, - pcms->boot_cpus, pcms->apic_id_limit); + x86ms->boot_cpus, x86ms->apic_id_limit); =20 rom_set_fw(fw_cfg); =20 @@ -1246,10 +1250,10 @@ void pc_memory_init(PCMachineState *pcms, for (i =3D 0; i < nb_option_roms; i++) { rom_add_option(option_rom[i].name, option_rom[i].bootindex); } - pcms->fw_cfg =3D fw_cfg; + x86ms->fw_cfg =3D fw_cfg; =20 /* Init default IOAPIC address space */ - pcms->ioapic_as =3D &address_space_memory; + x86ms->ioapic_as =3D &address_space_memory; =20 /* Init ACPI memory hotplug IO base address */ pcms->memhp_io_base =3D ACPI_MEMORY_HOTPLUG_BASE; @@ -1264,6 +1268,7 @@ uint64_t pc_pci_hole64_start(void) PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); MachineState *ms =3D MACHINE(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); uint64_t hole64_start =3D 0; =20 if (pcmc->has_reserved_memory && ms->device_memory->base) { @@ -1272,7 +1277,7 @@ uint64_t pc_pci_hole64_start(void) hole64_start +=3D memory_region_size(&ms->device_memory->mr); } } else { - hole64_start =3D 0x100000000ULL + pcms->above_4g_mem_size; + hole64_start =3D 0x100000000ULL + x86ms->above_4g_mem_size; } =20 return ROUND_UP(hole64_start, 1 * GiB); @@ -1611,6 +1616,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, Error *local_err =3D NULL; X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 if (pcms->acpi_dev) { hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_= err); @@ -1620,12 +1626,12 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, } =20 /* increment the number of CPUs */ - pcms->boot_cpus++; - if (pcms->rtc) { - rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus); + x86ms->boot_cpus++; + if (x86ms->rtc) { + rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus); } - if (pcms->fw_cfg) { - fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + if (x86ms->fw_cfg) { + fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); } =20 found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); @@ -1671,6 +1677,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, Error *local_err =3D NULL; X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_er= r); if (local_err) { @@ -1682,10 +1689,10 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplu= g_dev, object_property_set_bool(OBJECT(dev), false, "realized", NULL); =20 /* decrement the number of CPUs */ - pcms->boot_cpus--; + x86ms->boot_cpus--; /* Update the number of CPUs in CMOS */ - rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus); - fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus); + fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); out: error_propagate(errp, local_err); } @@ -1701,6 +1708,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, CPUX86State *env =3D &cpu->env; MachineState *ms =3D MACHINE(hotplug_dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + X86MachineState *x86ms =3D X86_MACHINE(pcms); unsigned int smp_cores =3D ms->smp.cores; unsigned int smp_threads =3D ms->smp.threads; =20 @@ -1710,7 +1718,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, return; } =20 - env->nr_dies =3D pcms->smp_dies; + env->nr_dies =3D x86ms->smp_dies; =20 /* * If APIC ID is not set, @@ -1718,13 +1726,13 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { int max_socket =3D (ms->smp.max_cpus - 1) / - smp_threads / smp_cores / pcms->smp_dies; + smp_threads / smp_cores / x86ms->smp_dies; =20 /* * die-id was optional in QEMU 4.0 and older, so keep it optional * if there's only one die per socket. */ - if (cpu->die_id < 0 && pcms->smp_dies =3D=3D 1) { + if (cpu->die_id < 0 && x86ms->smp_dies =3D=3D 1) { cpu->die_id =3D 0; } =20 @@ -1739,9 +1747,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, if (cpu->die_id < 0) { error_setg(errp, "CPU die-id is not set"); return; - } else if (cpu->die_id > pcms->smp_dies - 1) { + } else if (cpu->die_id > x86ms->smp_dies - 1) { error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u= ", - cpu->die_id, pcms->smp_dies - 1); + cpu->die_id, x86ms->smp_dies - 1); return; } if (cpu->core_id < 0) { @@ -1765,7 +1773,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, topo.die_id =3D cpu->die_id; topo.core_id =3D cpu->core_id; topo.smt_id =3D cpu->thread_id; - cpu->apic_id =3D apicid_from_topo_ids(pcms->smp_dies, smp_cores, + cpu->apic_id =3D apicid_from_topo_ids(x86ms->smp_dies, smp_cores, smp_threads, &topo); } =20 @@ -1773,7 +1781,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 - x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, + x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, smp_cores, smp_threads, &topo); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" @@ -1795,7 +1803,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizef= n() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globa= ls */ - x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, + x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, smp_cores, smp_threads, &topo); if (cpu->socket_id !=3D -1 && cpu->socket_id !=3D topo.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id= :" @@ -1977,45 +1985,6 @@ pc_machine_get_device_memory_region_size(Object *obj= , Visitor *v, visit_type_int(v, name, &value, errp); } =20 -static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - uint64_t value =3D pcms->max_ram_below_4g; - - visit_type_size(v, name, &value, errp); -} - -static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - Error *error =3D NULL; - uint64_t value; - - visit_type_size(v, name, &value, &error); - if (error) { - error_propagate(errp, error); - return; - } - if (value > 4 * GiB) { - error_setg(&error, - "Machine option 'max-ram-below-4g=3D%"PRIu64 - "' expects size less than or equal to 4G", value); - error_propagate(errp, error); - return; - } - - if (value < 1 * MiB) { - warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary= ," - "BIOS may not work with less than 1MiB", value); - } - - pcms->max_ram_below_4g =3D value; -} - static void pc_machine_get_vmport(Object *obj, Visitor *v, const char *nam= e, void *opaque, Error **errp) { @@ -2121,7 +2090,6 @@ static void pc_machine_initfn(Object *obj) { PCMachineState *pcms =3D PC_MACHINE(obj); =20 - pcms->max_ram_below_4g =3D 0; /* use default */ pcms->smm =3D ON_OFF_AUTO_AUTO; #ifdef CONFIG_VMPORT pcms->vmport =3D ON_OFF_AUTO_AUTO; @@ -2133,7 +2101,6 @@ static void pc_machine_initfn(Object *obj) pcms->smbus_enabled =3D true; pcms->sata_enabled =3D true; pcms->pit_enabled =3D true; - pcms->smp_dies =3D 1; =20 pc_system_flash_create(pcms); } @@ -2164,23 +2131,6 @@ static void pc_machine_wakeup(MachineState *machine) cpu_synchronize_all_post_reset(); } =20 -static void x86_nmi(NMIState *n, int cpu_index, Error **errp) -{ - /* cpu index isn't used */ - CPUState *cs; - - CPU_FOREACH(cs) { - X86CPU *cpu =3D X86_CPU(cs); - - if (!cpu->apic_state) { - cpu_interrupt(cs, CPU_INTERRUPT_NMI); - } else { - apic_deliver_nmi(cpu->apic_state); - } - } -} - - static bool pc_hotplug_allowed(MachineState *ms, DeviceState *dev, Error *= *errp) { X86IOMMUState *iommu =3D x86_iommu_get_default(); @@ -2205,7 +2155,6 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) MachineClass *mc =3D MACHINE_CLASS(oc); PCMachineClass *pcmc =3D PC_MACHINE_CLASS(oc); HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); - NMIClass *nc =3D NMI_CLASS(oc); =20 pcmc->pci_enabled =3D true; pcmc->has_acpi_build =3D true; @@ -2241,7 +2190,6 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) hc->plug =3D pc_machine_device_plug_cb; hc->unplug_request =3D pc_machine_device_unplug_request_cb; hc->unplug =3D pc_machine_device_unplug_cb; - nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D true; mc->numa_mem_supported =3D true; @@ -2250,13 +2198,6 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) pc_machine_get_device_memory_region_size, NULL, NULL, NULL, &error_abort); =20 - object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size", - pc_machine_get_max_ram_below_4g, pc_machine_set_max_ram_below_4g, - NULL, NULL, &error_abort); - - object_class_property_set_description(oc, PC_MACHINE_MAX_RAM_BELOW_4G, - "Maximum ram below the 4G boundary (32bit boundary)", &error_abort= ); - object_class_property_add(oc, PC_MACHINE_SMM, "OnOffAuto", pc_machine_get_smm, pc_machine_set_smm, NULL, NULL, &error_abort); @@ -2281,7 +2222,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) =20 static const TypeInfo pc_machine_info =3D { .name =3D TYPE_PC_MACHINE, - .parent =3D TYPE_MACHINE, + .parent =3D TYPE_X86_MACHINE, .abstract =3D true, .instance_size =3D sizeof(PCMachineState), .instance_init =3D pc_machine_initfn, @@ -2289,7 +2230,6 @@ static const TypeInfo pc_machine_info =3D { .class_init =3D pc_machine_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, - { TYPE_NMI }, { } }, }; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1396451..0afa8fe 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -74,6 +74,7 @@ static void pc_init1(MachineState *machine, { PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(machine); MemoryRegion *system_memory =3D get_system_memory(); MemoryRegion *system_io =3D get_system_io(); int i; @@ -126,11 +127,11 @@ static void pc_init1(MachineState *machine, if (xen_enabled()) { xen_hvm_init(pcms, &ram_memory); } else { - if (!pcms->max_ram_below_4g) { - pcms->max_ram_below_4g =3D 0xe0000000; /* default: 3.5G */ + if (!x86ms->max_ram_below_4g) { + x86ms->max_ram_below_4g =3D 0xe0000000; /* default: 3.5G */ } - lowmem =3D pcms->max_ram_below_4g; - if (machine->ram_size >=3D pcms->max_ram_below_4g) { + lowmem =3D x86ms->max_ram_below_4g; + if (machine->ram_size >=3D x86ms->max_ram_below_4g) { if (pcmc->gigabyte_align) { if (lowmem > 0xc0000000) { lowmem =3D 0xc0000000; @@ -139,17 +140,17 @@ static void pc_init1(MachineState *machine, warn_report("Large machine and max_ram_below_4g " "(%" PRIu64 ") not a multiple of 1G; " "possible bad performance.", - pcms->max_ram_below_4g); + x86ms->max_ram_below_4g); } } } =20 if (machine->ram_size >=3D lowmem) { - pcms->above_4g_mem_size =3D machine->ram_size - lowmem; - pcms->below_4g_mem_size =3D lowmem; + x86ms->above_4g_mem_size =3D machine->ram_size - lowmem; + x86ms->below_4g_mem_size =3D lowmem; } else { - pcms->above_4g_mem_size =3D 0; - pcms->below_4g_mem_size =3D machine->ram_size; + x86ms->above_4g_mem_size =3D 0; + x86ms->below_4g_mem_size =3D machine->ram_size; } } =20 @@ -191,19 +192,19 @@ static void pc_init1(MachineState *machine, gsi_state =3D g_malloc0(sizeof(*gsi_state)); if (kvm_ioapic_in_kernel()) { kvm_pc_setup_irq_routing(pcmc->pci_enabled); - pcms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, + x86ms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, GSI_NUM_PINS); } else { - pcms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_P= INS); + x86ms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_= PINS); } =20 if (pcmc->pci_enabled) { pci_bus =3D i440fx_init(host_type, pci_type, - &i440fx_state, &piix3_devfn, &isa_bus, pcms-= >gsi, + &i440fx_state, &piix3_devfn, &isa_bus, x86ms= ->gsi, system_memory, system_io, machine->ram_size, - pcms->below_4g_mem_size, - pcms->above_4g_mem_size, + x86ms->below_4g_mem_size, + x86ms->above_4g_mem_size, pci_memory, ram_memory); pcms->bus =3D pci_bus; } else { @@ -213,7 +214,7 @@ static void pc_init1(MachineState *machine, &error_abort); no_hpet =3D 1; } - isa_bus_irqs(isa_bus, pcms->gsi); + isa_bus_irqs(isa_bus, x86ms->gsi); =20 if (kvm_pic_in_kernel()) { i8259 =3D kvm_i8259_init(isa_bus); @@ -231,7 +232,7 @@ static void pc_init1(MachineState *machine, ioapic_init_gsi(gsi_state, "i440fx"); } =20 - pc_register_ferr_irq(pcms->gsi[13]); + pc_register_ferr_irq(x86ms->gsi[13]); =20 pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); =20 @@ -241,7 +242,7 @@ static void pc_init1(MachineState *machine, } =20 /* init basic PC hardware */ - pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true, + pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true, (pcms->vmport !=3D ON_OFF_AUTO_ON), pcms->pit_ena= bled, 0x4); =20 @@ -288,7 +289,7 @@ else { smi_irq =3D qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); /* TODO: Populate SPD eeprom data. */ pcms->smbus =3D piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, - pcms->gsi[9], smi_irq, + x86ms->gsi[9], smi_irq, pc_machine_is_smm_enabled(pcms), &piix4_pm); smbus_eeprom_init(pcms->smbus, 8, NULL, 0); @@ -304,7 +305,7 @@ else { =20 if (machine->nvdimms_state->is_enabled) { nvdimm_init_acpi_state(machine->nvdimms_state, system_io, - pcms->fw_cfg, OBJECT(pcms)); + x86ms->fw_cfg, OBJECT(pcms)); } } =20 @@ -729,7 +730,7 @@ DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_= 1_4_fn, =20 static void pc_i440fx_1_3_machine_options(MachineClass *m) { - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); + X86MachineClass *x86mc =3D X86_MACHINE_CLASS(m); static GlobalProperty compat[] =3D { PC_CPU_MODEL_IDS("1.3.0") { "usb-tablet", "usb_version", "1" }, @@ -740,7 +741,7 @@ static void pc_i440fx_1_3_machine_options(MachineClass = *m) =20 pc_i440fx_1_4_machine_options(m); m->hw_version =3D "1.3.0"; - pcmc->compat_apic_id_mode =3D true; + x86mc->compat_apic_id_mode =3D true; compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat)); } =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 8920bd8..374ac6c 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -116,6 +116,7 @@ static void pc_q35_init(MachineState *machine) { PCMachineState *pcms =3D PC_MACHINE(machine); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(machine); Q35PCIHost *q35_host; PCIHostState *phb; PCIBus *host_bus; @@ -153,27 +154,27 @@ static void pc_q35_init(MachineState *machine) /* Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit). */ - if (!pcms->max_ram_below_4g) { - pcms->max_ram_below_4g =3D 1ULL << 32; /* default: 4G */; + if (!x86ms->max_ram_below_4g) { + x86ms->max_ram_below_4g =3D 4 * GiB; } - if (lowmem > pcms->max_ram_below_4g) { - lowmem =3D pcms->max_ram_below_4g; + if (lowmem > x86ms->max_ram_below_4g) { + lowmem =3D x86ms->max_ram_below_4g; if (machine->ram_size - lowmem > lowmem && lowmem & (1 * GiB - 1)) { warn_report("There is possibly poor performance as the ram siz= e " " (0x%" PRIx64 ") is more then twice the size of" " max-ram-below-4g (%"PRIu64") and" " max-ram-below-4g is not a multiple of 1G.", - (uint64_t)machine->ram_size, pcms->max_ram_below_4= g); + (uint64_t)machine->ram_size, x86ms->max_ram_below_= 4g); } } =20 if (machine->ram_size >=3D lowmem) { - pcms->above_4g_mem_size =3D machine->ram_size - lowmem; - pcms->below_4g_mem_size =3D lowmem; + x86ms->above_4g_mem_size =3D machine->ram_size - lowmem; + x86ms->below_4g_mem_size =3D lowmem; } else { - pcms->above_4g_mem_size =3D 0; - pcms->below_4g_mem_size =3D machine->ram_size; + x86ms->above_4g_mem_size =3D 0; + x86ms->below_4g_mem_size =3D machine->ram_size; } =20 if (xen_enabled()) { @@ -214,10 +215,10 @@ static void pc_q35_init(MachineState *machine) gsi_state =3D g_malloc0(sizeof(*gsi_state)); if (kvm_ioapic_in_kernel()) { kvm_pc_setup_irq_routing(pcmc->pci_enabled); - pcms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, + x86ms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, GSI_NUM_PINS); } else { - pcms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_P= INS); + x86ms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_= PINS); } =20 /* create pci host bus */ @@ -232,9 +233,9 @@ static void pc_q35_init(MachineState *machine) MCH_HOST_PROP_SYSTEM_MEM, NULL); object_property_set_link(OBJECT(q35_host), OBJECT(system_io), MCH_HOST_PROP_IO_MEM, NULL); - object_property_set_int(OBJECT(q35_host), pcms->below_4g_mem_size, + object_property_set_int(OBJECT(q35_host), x86ms->below_4g_mem_size, PCI_HOST_BELOW_4G_MEM_SIZE, NULL); - object_property_set_int(OBJECT(q35_host), pcms->above_4g_mem_size, + object_property_set_int(OBJECT(q35_host), x86ms->above_4g_mem_size, PCI_HOST_ABOVE_4G_MEM_SIZE, NULL); /* pci */ qdev_init_nofail(DEVICE(q35_host)); @@ -256,7 +257,7 @@ static void pc_q35_init(MachineState *machine) ich9_lpc =3D ICH9_LPC_DEVICE(lpc); lpc_dev =3D DEVICE(lpc); for (i =3D 0; i < GSI_NUM_PINS; i++) { - qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, pcms->gsi[i= ]); + qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, x86ms->gsi[= i]); } pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc, ICH9_LPC_NB_PIRQS); @@ -280,7 +281,7 @@ static void pc_q35_init(MachineState *machine) ioapic_init_gsi(gsi_state, "q35"); } =20 - pc_register_ferr_irq(pcms->gsi[13]); + pc_register_ferr_irq(x86ms->gsi[13]); =20 assert(pcms->vmport !=3D ON_OFF_AUTO__MAX); if (pcms->vmport =3D=3D ON_OFF_AUTO_AUTO) { @@ -288,7 +289,7 @@ static void pc_q35_init(MachineState *machine) } =20 /* init basic PC hardware */ - pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, !mc->no_floppy, + pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy, (pcms->vmport !=3D ON_OFF_AUTO_ON), pcms->pit_ena= bled, 0xff0104); =20 @@ -331,7 +332,7 @@ static void pc_q35_init(MachineState *machine) =20 if (machine->nvdimms_state->is_enabled) { nvdimm_init_acpi_state(machine->nvdimms_state, system_io, - pcms->fw_cfg, OBJECT(pcms)); + x86ms->fw_cfg, OBJECT(pcms)); } } =20 diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 71fb093..de4fed0 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -65,13 +65,14 @@ uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcm= s, unsigned int cpu_index) { MachineState *ms =3D MACHINE(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); + X86MachineClass *x86mc =3D X86_MACHINE_GET_CLASS(x86ms); uint32_t correct_id; static bool warned; =20 - correct_id =3D x86_apicid_from_cpu_idx(pcms->smp_dies, ms->smp.cores, + correct_id =3D x86_apicid_from_cpu_idx(x86ms->smp_dies, ms->smp.cores, ms->smp.threads, cpu_index); - if (pcmc->compat_apic_id_mode) { + if (x86mc->compat_apic_id_mode) { if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " "CPU topology won't match the configuration"); @@ -88,11 +89,12 @@ void x86_cpu_new(PCMachineState *pcms, int64_t apic_id,= Error **errp) Object *cpu =3D NULL; Error *local_err =3D NULL; CPUX86State *env =3D NULL; + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 cpu =3D object_new(MACHINE(pcms)->cpu_type); =20 env =3D &X86_CPU(cpu)->env; - env->nr_dies =3D pcms->smp_dies; + env->nr_dies =3D x86ms->smp_dies; =20 object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); @@ -108,6 +110,7 @@ void x86_cpus_init(PCMachineState *pcms) MachineState *ms =3D MACHINE(pcms); MachineClass *mc =3D MACHINE_GET_CLASS(pcms); PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); + X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 x86_cpu_set_default_version(pcmc->default_cpu_version); =20 @@ -119,8 +122,8 @@ void x86_cpus_init(PCMachineState *pcms) * * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_creat= e(). */ - pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, - ms->smp.max_cpus - 1)= + 1; + x86ms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, + ms->smp.max_cpus - 1= ) + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < ms->smp.cpus; i++) { x86_cpu_new(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); @@ -140,11 +143,11 @@ x86_cpu_index_to_props(MachineState *ms, unsigned cpu= _index) int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) { X86CPUTopoInfo topo; - PCMachineState *pcms =3D PC_MACHINE(ms); + X86MachineState *x86ms =3D X86_MACHINE(ms); =20 assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - pcms->smp_dies, ms->smp.cores, + x86ms->smp_dies, ms->smp.cores, ms->smp.threads, &topo); return topo.pkg_id % ms->numa_state->num_nodes; } @@ -152,6 +155,7 @@ int64_t x86_get_default_cpu_node_id(const MachineState = *ms, int idx) const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) { PCMachineState *pcms =3D PC_MACHINE(ms); + X86MachineState *x86ms =3D X86_MACHINE(ms); int i; unsigned int max_cpus =3D ms->smp.max_cpus; =20 @@ -175,11 +179,11 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(Machin= eState *ms) ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(pcms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - pcms->smp_dies, ms->smp.cores, + x86ms->smp_dies, ms->smp.cores, ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; - if (pcms->smp_dies > 1) { + if (x86ms->smp_dies > 1) { ms->possible_cpus->cpus[i].props.has_die_id =3D true; ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; } @@ -191,6 +195,22 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(Machine= State *ms) return ms->possible_cpus; } =20 +static void x86_nmi(NMIState *n, int cpu_index, Error **errp) +{ + /* cpu index isn't used */ + CPUState *cs; + + CPU_FOREACH(cs) { + X86CPU *cpu =3D X86_CPU(cs); + + if (!cpu->apic_state) { + cpu_interrupt(cs, CPU_INTERRUPT_NMI); + } else { + apic_deliver_nmi(cpu->apic_state); + } + } +} + static long get_file_size(FILE *f) { long where, size; @@ -328,6 +348,7 @@ void x86_load_linux(PCMachineState *pcms, char *vmode; MachineState *machine =3D MACHINE(pcms); PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms =3D X86_MACHINE(pcms); struct setup_data *setup_data; const char *kernel_filename =3D machine->kernel_filename; const char *initrd_filename =3D machine->initrd_filename; @@ -400,11 +421,12 @@ void x86_load_linux(PCMachineState *pcms, initrd_filename, gerr->message); exit(1); } - pcms->initrd_mapped_file =3D mapped_file; + x86ms->initrd_mapped_file =3D mapped_file; =20 initrd_data =3D g_mapped_file_get_contents(mapped_file); initrd_size =3D g_mapped_file_get_length(mapped_file); - initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_s= ize - 1; + initrd_max =3D + x86ms->below_4g_mem_size - pcmc->acpi_data_size - 1; if (initrd_size >=3D initrd_max) { fprintf(stderr, "qemu: initrd is too large, cannot sup= port." "(max: %"PRIu32", need %"PRId64")\n", @@ -472,8 +494,8 @@ void x86_load_linux(PCMachineState *pcms, initrd_max =3D 0x37ffffff; } =20 - if (initrd_max >=3D pcms->below_4g_mem_size - pcmc->acpi_data_size) { - initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_size - 1; + if (initrd_max >=3D x86ms->below_4g_mem_size - pcmc->acpi_data_size) { + initrd_max =3D x86ms->below_4g_mem_size - pcmc->acpi_data_size - 1; } =20 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); @@ -544,7 +566,7 @@ void x86_load_linux(PCMachineState *pcms, initrd_filename, gerr->message); exit(1); } - pcms->initrd_mapped_file =3D mapped_file; + x86ms->initrd_mapped_file =3D mapped_file; =20 initrd_data =3D g_mapped_file_get_contents(mapped_file); initrd_size =3D g_mapped_file_get_length(mapped_file); @@ -688,3 +710,91 @@ void x86_bios_rom_init(MemoryRegion *rom_memory, bool = isapc_ram_fw) (uint32_t)(-bios_size), bios); } + +static void x86_machine_get_max_ram_below_4g(Object *obj, Visitor *v, + const char *name, void *opaqu= e, + Error **errp) +{ + X86MachineState *x86ms =3D X86_MACHINE(obj); + uint64_t value =3D x86ms->max_ram_below_4g; + + visit_type_size(v, name, &value, errp); +} + +static void x86_machine_set_max_ram_below_4g(Object *obj, Visitor *v, + const char *name, void *opaqu= e, + Error **errp) +{ + X86MachineState *x86ms =3D X86_MACHINE(obj); + Error *error =3D NULL; + uint64_t value; + + visit_type_size(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + if (value > 4 * GiB) { + error_setg(&error, + "Machine option 'max-ram-below-4g=3D%"PRIu64 + "' expects size less than or equal to 4G", value); + error_propagate(errp, error); + return; + } + + if (value < 1 * MiB) { + warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary= ," + "BIOS may not work with less than 1MiB", value); + } + + x86ms->max_ram_below_4g =3D value; +} + +static void x86_machine_initfn(Object *obj) +{ + X86MachineState *x86ms =3D X86_MACHINE(obj); + + x86ms->max_ram_below_4g =3D 0; /* use default */ + x86ms->smp_dies =3D 1; +} + +static void x86_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + X86MachineClass *x86mc =3D X86_MACHINE_CLASS(oc); + NMIClass *nc =3D NMI_CLASS(oc); + + mc->cpu_index_to_instance_props =3D x86_cpu_index_to_props; + mc->get_default_cpu_node_id =3D x86_get_default_cpu_node_id; + mc->possible_cpu_arch_ids =3D x86_possible_cpu_arch_ids; + x86mc->compat_apic_id_mode =3D false; + nc->nmi_monitor_handler =3D x86_nmi; + + object_class_property_add(oc, X86_MACHINE_MAX_RAM_BELOW_4G, "size", + x86_machine_get_max_ram_below_4g, x86_machine_set_max_ram_below_4g, + NULL, NULL, &error_abort); + + object_class_property_set_description(oc, X86_MACHINE_MAX_RAM_BELOW_4G, + "Maximum ram below the 4G boundary (32bit boundary)", &error_abort= ); +} + +static const TypeInfo x86_machine_info =3D { + .name =3D TYPE_X86_MACHINE, + .parent =3D TYPE_MACHINE, + .abstract =3D true, + .instance_size =3D sizeof(X86MachineState), + .instance_init =3D x86_machine_initfn, + .class_size =3D sizeof(X86MachineClass), + .class_init =3D x86_machine_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_NMI }, + { } + }, +}; + +static void x86_machine_register_types(void) +{ + type_register_static(&x86_machine_info); +} + +type_init(x86_machine_register_types) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 6b5e5bb..95f23a2 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -197,11 +197,13 @@ qemu_irq *xen_interrupt_controller_init(void) static void xen_ram_init(PCMachineState *pcms, ram_addr_t ram_size, MemoryRegion **ram_memory_p) { + X86MachineState *x86ms =3D X86_MACHINE(pcms); MemoryRegion *sysmem =3D get_system_memory(); ram_addr_t block_len; - uint64_t user_lowmem =3D object_property_get_uint(qdev_get_machine(), - PC_MACHINE_MAX_RAM_BEL= OW_4G, - &error_abort); + uint64_t user_lowmem =3D + object_property_get_uint(qdev_get_machine(), + X86_MACHINE_MAX_RAM_BELOW_4G, + &error_abort); =20 /* Handle the machine opt max-ram-below-4g. It is basically doing * min(xen limit, user limit). @@ -214,20 +216,20 @@ static void xen_ram_init(PCMachineState *pcms, } =20 if (ram_size >=3D user_lowmem) { - pcms->above_4g_mem_size =3D ram_size - user_lowmem; - pcms->below_4g_mem_size =3D user_lowmem; + x86ms->above_4g_mem_size =3D ram_size - user_lowmem; + x86ms->below_4g_mem_size =3D user_lowmem; } else { - pcms->above_4g_mem_size =3D 0; - pcms->below_4g_mem_size =3D ram_size; + x86ms->above_4g_mem_size =3D 0; + x86ms->below_4g_mem_size =3D ram_size; } - if (!pcms->above_4g_mem_size) { + if (!x86ms->above_4g_mem_size) { block_len =3D ram_size; } else { /* * Xen does not allocate the memory continuously, it keeps a * hole of the size computed above or passed in. */ - block_len =3D (1ULL << 32) + pcms->above_4g_mem_size; + block_len =3D (1ULL << 32) + x86ms->above_4g_mem_size; } memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, &error_fatal); @@ -244,12 +246,12 @@ static void xen_ram_init(PCMachineState *pcms, */ memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory, 0xc0000, - pcms->below_4g_mem_size - 0xc0000); + x86ms->below_4g_mem_size - 0xc0000); memory_region_add_subregion(sysmem, 0xc0000, &ram_lo); - if (pcms->above_4g_mem_size > 0) { + if (x86ms->above_4g_mem_size > 0) { memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory, 0x100000000ULL, - pcms->above_4g_mem_size); + x86ms->above_4g_mem_size); memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi); } } @@ -265,7 +267,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size= , MemoryRegion *mr, /* RAM already populated in Xen */ fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E\n", - __func__, size, ram_addr);=20 + __func__, size, ram_addr); return; } =20 diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 1ede055..ead14e1 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -89,7 +89,7 @@ static void ioapic_entry_parse(uint64_t entry, struct ioa= pic_entry_info *info) =20 static void ioapic_service(IOAPICCommonState *s) { - AddressSpace *ioapic_as =3D PC_MACHINE(qdev_get_machine())->ioapic_as; + AddressSpace *ioapic_as =3D X86_MACHINE(qdev_get_machine())->ioapic_as; struct ioapic_entry_info info; uint8_t i; uint32_t mask; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f135ae8..13c4eac 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -8,6 +8,7 @@ #include "hw/block/flash.h" #include "net/net.h" #include "hw/i386/ioapic.h" +#include "hw/i386/x86.h" =20 #include "qemu/range.h" #include "qemu/bitmap.h" @@ -27,7 +28,7 @@ */ struct PCMachineState { /*< private >*/ - MachineState parent_obj; + X86MachineState parent_obj; =20 /* */ =20 @@ -36,16 +37,11 @@ struct PCMachineState { =20 /* Pointers to devices and objects: */ HotplugHandler *acpi_dev; - ISADevice *rtc; PCIBus *bus; I2CBus *smbus; - FWCfgState *fw_cfg; - qemu_irq *gsi; PFlashCFI01 *flash[2]; - GMappedFile *initrd_mapped_file; =20 /* Configuration options: */ - uint64_t max_ram_below_4g; OnOffAuto vmport; OnOffAuto smm; =20 @@ -54,30 +50,16 @@ struct PCMachineState { bool sata_enabled; bool pit_enabled; =20 - /* RAM information (sizes, addresses, configuration): */ - ram_addr_t below_4g_mem_size, above_4g_mem_size; - - /* CPU and apic information: */ - bool apic_xrupt_override; - unsigned apic_id_limit; - uint16_t boot_cpus; - unsigned smp_dies; - /* NUMA information: */ uint64_t numa_nodes; uint64_t *node_mem; =20 - /* Address space used by IOAPIC device. All IOAPIC interrupts - * will be translated to MSI messages in the address space. */ - AddressSpace *ioapic_as; - /* ACPI Memory hotplug IO base address */ hwaddr memhp_io_base; }; =20 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" #define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size" -#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" #define PC_MACHINE_VMPORT "vmport" #define PC_MACHINE_SMM "smm" #define PC_MACHINE_SMBUS "smbus" @@ -102,7 +84,7 @@ struct PCMachineState { */ typedef struct PCMachineClass { /*< private >*/ - MachineClass parent_class; + X86MachineClass parent_class; =20 /*< public >*/ =20 @@ -144,9 +126,6 @@ typedef struct PCMachineClass { =20 /* use PVH to load kernels that support this feature */ bool pvh_enabled; - - /* Enables contiguous-apic-ID mode */ - bool compat_apic_id_mode; } PCMachineClass; =20 #define TYPE_PC_MACHINE "generic-pc-machine" diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 71e2b69..d15713e 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -17,7 +17,63 @@ #ifndef HW_I386_X86_H #define HW_I386_X86_H =20 +#include "qemu-common.h" +#include "exec/hwaddr.h" +#include "qemu/notify.h" + #include "hw/boards.h" +#include "hw/nmi.h" + +typedef struct { + /*< private >*/ + MachineClass parent; + + /*< public >*/ + + /* Enables contiguous-apic-ID mode */ + bool compat_apic_id_mode; +} X86MachineClass; + +typedef struct { + /*< private >*/ + MachineState parent; + + /*< public >*/ + + /* Pointers to devices and objects: */ + ISADevice *rtc; + FWCfgState *fw_cfg; + qemu_irq *gsi; + GMappedFile *initrd_mapped_file; + + /* Configuration options: */ + uint64_t max_ram_below_4g; + + /* RAM information (sizes, addresses, configuration): */ + ram_addr_t below_4g_mem_size, above_4g_mem_size; + + /* CPU and apic information: */ + bool apic_xrupt_override; + unsigned apic_id_limit; + uint16_t boot_cpus; + unsigned smp_dies; + + /* + * Address space used by IOAPIC device. All IOAPIC interrupts + * will be translated to MSI messages in the address space. + */ + AddressSpace *ioapic_as; +} X86MachineState; + +#define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" + +#define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86") +#define X86_MACHINE(obj) \ + OBJECT_CHECK(X86MachineState, (obj), TYPE_X86_MACHINE) +#define X86_MACHINE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(X86MachineClass, obj, TYPE_X86_MACHINE) +#define X86_MACHINE_CLASS(class) \ + OBJECT_CLASS_CHECK(X86MachineClass, class, TYPE_X86_MACHINE) =20 uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, unsigned int cpu_index); @@ -30,6 +86,6 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineSta= te *ms); =20 void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw); =20 -void x86_load_linux(PCMachineState *x86ms, FWCfgState *fw_cfg); +void x86_load_linux(PCMachineState *pcms, FWCfgState *fw_cfg); =20 #endif --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928418; cv=none; d=zoho.com; s=zohoarc; b=Tz7Fs+AaiY/dsgpyoAMHUkN6K/NRb9CvkhYS7PsFGs4dGYgNRl2aQdgmRiRt35G/BeKHHYC2QUF/YSjYgmBsVxexUDFFy35wgRW25KotmZSk1UWmrAT/f7KPqaL4LFkOriD5wiXMH6oUMiwxUvHKwQVeA/UPeuY3hc4UoOmsYgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928418; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9Asy+EBJ1/DDN/7vzodpurF+OtN2EzDDhF7AXA5N1ZU=; b=FxYxggnhhFnKH/3ZFzYqH18XgQBsAOj4icsGQakyoDDQE+WibYSw/IEnh4WT+vZqmB1pwKLfuobs/L/5DXTn8qI7JZ0sDxaNvbOA6qnUPaRp0CeHGBSbAhQMxWDrr8PSP2SmOD5XNTglndk2xBHI5VIlQdYNQYQok2U0l1EOUkI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928418016451.9880258232182; Thu, 24 Oct 2019 07:46:58 -0700 (PDT) Received: from localhost ([::1]:44520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeO6-00079A-S2 for importer@patchew.org; Thu, 24 Oct 2019 10:46:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34773) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiw-0007mu-1C for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdit-0007is-GZ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:34394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdir-0007hO-PM for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id v3so2078072wmh.1 for ; Thu, 24 Oct 2019 07:04:16 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Asy+EBJ1/DDN/7vzodpurF+OtN2EzDDhF7AXA5N1ZU=; b=KqpXAxEm7FMlXeqQ7esGju6LSVeHa78VE6YIJ9h/PEo7gXgObC/LtqALuVCTCeVkvl lApQF5n1W2mCQXm7L6kAS3zqxFONRQtuLlJFm9MB6/06Xog8hGRwlpDav6vkWRsBORlY hkPUP90YiIh+ikvdVcSGBDantabrAsk1eWhKJa9Ap+vni6cgjbxC+OCxcAz40n4PviNc pDXSflpoJyu2CZPjJUiGb3UCPj/XkfecAfckq/agJYCnyaMU3nT0dUwMXX7m4/oySU9k IbDaQpoKGz0tcVTO+x9NrJTq+pUT78scSyGWkmYh1w/9Bn/QpKAb+9ynet2B/xfPV/K6 wXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9Asy+EBJ1/DDN/7vzodpurF+OtN2EzDDhF7AXA5N1ZU=; b=V03N/kuFxPQA1ijxoFhJN3H0gad7B5cSEM8TBlSSnsjc8TI/TaTixd/LONEaQBi43T nQrAy1w3wVeI2WRQzbB0ktAc05RtNbFEv7EkvbiBSyTR5DSe4hHais0MFTOqzgDl2lzd tFcn90OWw3RTwSfrFKWsavlWV7h+SBL1PD8rNGxVOoPZFac2wvAMcWIMnTO0I95WxDLK K80Raqy96EswKwNGlEWmVvaUgt7izEfPe6JfIdD1CVrFqVpRumzjR4CjY3MIfDYHD63v afUtR7wGkNB8xycknhItGhvyZLt4is6HpqZqbb7C6aaRYStnqUwXBotD7dJZsnryfka3 bTVA== X-Gm-Message-State: APjAAAX61NHHcuQN0wkfw2UFIeTyIwxd+E/KEfkvCD3GEw+U2vhznHRd ycUytgBBn+wny1IfUgJLLC+77C6j X-Google-Smtp-Source: APXvYqyFZy3ZxxlDbhW5MvHqmghTkfOvqVwAxSEWgrV3L/n7+wFYQaS1JZKugaI7qCyWP6HRWBFz7g== X-Received: by 2002:a1c:9ec6:: with SMTP id h189mr4817182wme.71.1571925854459; Thu, 24 Oct 2019 07:04:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/39] hw/i386: make x86.c independent from PCMachineState Date: Thu, 24 Oct 2019 16:03:31 +0200 Message-Id: <1571925835-31930-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez As a last step into splitting PCMachineState and deriving X86MachineState from it, make the functions previously extracted from pc.c to x86.c independent from PCMachineState, using X86MachineState instead. Signed-off-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- hw/i386/pc.c | 14 +++++++++----- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/x86.c | 53 +++++++++++++++++++++++------------------------= ---- include/hw/i386/x86.h | 13 +++++++++---- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e6ad1f1..a8888dd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -983,8 +983,8 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) =20 void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) { - PCMachineState *pcms =3D PC_MACHINE(ms); - int64_t apic_id =3D x86_cpu_apic_id_from_index(pcms, id); + X86MachineState *x86ms =3D X86_MACHINE(ms); + int64_t apic_id =3D x86_cpu_apic_id_from_index(x86ms, id); Error *local_err =3D NULL; =20 if (id < 0) { @@ -999,7 +999,8 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t id,= Error **errp) return; } =20 - x86_cpu_new(PC_MACHINE(ms), apic_id, &local_err); + + x86_cpu_new(X86_MACHINE(ms), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1100,6 +1101,7 @@ void xen_load_linux(PCMachineState *pcms) { int i; FWCfgState *fw_cfg; + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 assert(MACHINE(pcms)->kernel_filename !=3D NULL); @@ -1108,7 +1110,8 @@ void xen_load_linux(PCMachineState *pcms) fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); rom_set_fw(fw_cfg); =20 - x86_load_linux(pcms, fw_cfg); + x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size, + pcmc->pvh_enabled, pcmc->linuxboot_dma_enabled); for (i =3D 0; i < nb_option_roms; i++) { assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") || @@ -1244,7 +1247,8 @@ void pc_memory_init(PCMachineState *pcms, } =20 if (linux_boot) { - x86_load_linux(pcms, fw_cfg); + x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size, + pcmc->pvh_enabled, pcmc->linuxboot_dma_enabled); } =20 for (i =3D 0; i < nb_option_roms; i++) { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0afa8fe..a86317c 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -154,7 +154,7 @@ static void pc_init1(MachineState *machine, } } =20 - x86_cpus_init(pcms); + x86_cpus_init(x86ms, pcmc->default_cpu_version); =20 if (kvm_enabled() && pcmc->kvmclock_enabled) { kvmclock_create(); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 374ac6c..75c8caf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -181,7 +181,7 @@ static void pc_q35_init(MachineState *machine) xen_hvm_init(pcms, &ram_memory); } =20 - x86_cpus_init(pcms); + x86_cpus_init(x86ms, pcmc->default_cpu_version); =20 kvmclock_create(); =20 diff --git a/hw/i386/x86.c b/hw/i386/x86.c index de4fed0..fd84b23 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -36,7 +36,6 @@ #include "sysemu/sysemu.h" =20 #include "hw/i386/x86.h" -#include "hw/i386/pc.h" #include "target/i386/cpu.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" @@ -61,11 +60,10 @@ static size_t pvh_start_addr; * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC = ID of * all CPUs up to max_cpus. */ -uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, +uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, unsigned int cpu_index) { - MachineState *ms =3D MACHINE(pcms); - X86MachineState *x86ms =3D X86_MACHINE(pcms); + MachineState *ms =3D MACHINE(x86ms); X86MachineClass *x86mc =3D X86_MACHINE_GET_CLASS(x86ms); uint32_t correct_id; static bool warned; @@ -84,14 +82,14 @@ uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcm= s, } } =20 -void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **errp) + +void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp) { Object *cpu =3D NULL; Error *local_err =3D NULL; CPUX86State *env =3D NULL; - X86MachineState *x86ms =3D X86_MACHINE(pcms); =20 - cpu =3D object_new(MACHINE(pcms)->cpu_type); + cpu =3D object_new(MACHINE(x86ms)->cpu_type); =20 env =3D &X86_CPU(cpu)->env; env->nr_dies =3D x86ms->smp_dies; @@ -103,30 +101,28 @@ void x86_cpu_new(PCMachineState *pcms, int64_t apic_i= d, Error **errp) error_propagate(errp, local_err); } =20 -void x86_cpus_init(PCMachineState *pcms) +void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) { int i; const CPUArchIdList *possible_cpus; - MachineState *ms =3D MACHINE(pcms); - MachineClass *mc =3D MACHINE_GET_CLASS(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); - X86MachineState *x86ms =3D X86_MACHINE(pcms); + MachineState *ms =3D MACHINE(x86ms); + MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); =20 - x86_cpu_set_default_version(pcmc->default_cpu_version); + x86_cpu_set_default_version(default_cpu_version); =20 /* * Calculates the limit to CPU APIC ID values * * Limit for the APIC ID value, so that all - * CPU APIC IDs are < pcms->apic_id_limit. + * CPU APIC IDs are < x86ms->apic_id_limit. * * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_creat= e(). */ - x86ms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, + x86ms->apic_id_limit =3D x86_cpu_apic_id_from_index(x86ms, ms->smp.max_cpus - 1= ) + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < ms->smp.cpus; i++) { - x86_cpu_new(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); + x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal); } } =20 @@ -154,7 +150,6 @@ int64_t x86_get_default_cpu_node_id(const MachineState = *ms, int idx) =20 const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) { - PCMachineState *pcms =3D PC_MACHINE(ms); X86MachineState *x86ms =3D X86_MACHINE(ms); int i; unsigned int max_cpus =3D ms->smp.max_cpus; @@ -177,7 +172,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineS= tate *ms) ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D - x86_cpu_apic_id_from_index(pcms, i); + x86_cpu_apic_id_from_index(x86ms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, x86ms->smp_dies, ms->smp.cores, ms->smp.threads, &topo); @@ -335,8 +330,11 @@ static bool load_elfboot(const char *kernel_filename, return true; } =20 -void x86_load_linux(PCMachineState *pcms, - FWCfgState *fw_cfg) +void x86_load_linux(X86MachineState *x86ms, + FWCfgState *fw_cfg, + int acpi_data_size, + bool pvh_enabled, + bool linuxboot_dma_enabled) { uint16_t protocol; int setup_size, kernel_size, cmdline_size; @@ -346,9 +344,7 @@ void x86_load_linux(PCMachineState *pcms, hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =3D 0; FILE *f; char *vmode; - MachineState *machine =3D MACHINE(pcms); - PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms =3D X86_MACHINE(pcms); + MachineState *machine =3D MACHINE(x86ms); struct setup_data *setup_data; const char *kernel_filename =3D machine->kernel_filename; const char *initrd_filename =3D machine->initrd_filename; @@ -395,7 +391,7 @@ void x86_load_linux(PCMachineState *pcms, * saving the PVH entry point used by the x86/HVM direct boot ABI. * If load_elfboot() is successful, populate the fw_cfg info. */ - if (pcmc->pvh_enabled && + if (pvh_enabled && load_elfboot(kernel_filename, kernel_size, header, pvh_start_addr, fw_cfg)) { fclose(f); @@ -425,8 +421,7 @@ void x86_load_linux(PCMachineState *pcms, =20 initrd_data =3D g_mapped_file_get_contents(mapped_file); initrd_size =3D g_mapped_file_get_length(mapped_file); - initrd_max =3D - x86ms->below_4g_mem_size - pcmc->acpi_data_size - 1; + initrd_max =3D x86ms->below_4g_mem_size - acpi_data_size -= 1; if (initrd_size >=3D initrd_max) { fprintf(stderr, "qemu: initrd is too large, cannot sup= port." "(max: %"PRIu32", need %"PRId64")\n", @@ -494,8 +489,8 @@ void x86_load_linux(PCMachineState *pcms, initrd_max =3D 0x37ffffff; } =20 - if (initrd_max >=3D x86ms->below_4g_mem_size - pcmc->acpi_data_size) { - initrd_max =3D x86ms->below_4g_mem_size - pcmc->acpi_data_size - 1; + if (initrd_max >=3D x86ms->below_4g_mem_size - acpi_data_size) { + initrd_max =3D x86ms->below_4g_mem_size - acpi_data_size - 1; } =20 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); @@ -652,7 +647,7 @@ void x86_load_linux(PCMachineState *pcms, =20 option_rom[nb_option_roms].bootindex =3D 0; option_rom[nb_option_roms].name =3D "linuxboot.bin"; - if (pcmc->linuxboot_dma_enabled && fw_cfg_dma_enabled(fw_cfg)) { + if (linuxboot_dma_enabled && fw_cfg_dma_enabled(fw_cfg)) { option_rom[nb_option_roms].name =3D "linuxboot_dma.bin"; } nb_option_roms++; diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index d15713e..82d09fd 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -75,10 +75,11 @@ typedef struct { #define X86_MACHINE_CLASS(class) \ OBJECT_CLASS_CHECK(X86MachineClass, class, TYPE_X86_MACHINE) =20 -uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, +uint32_t x86_cpu_apic_id_from_index(X86MachineState *pcms, unsigned int cpu_index); -void x86_cpu_new(PCMachineState *pcms, int64_t apic_id, Error **errp); -void x86_cpus_init(PCMachineState *pcms); + +void x86_cpu_new(X86MachineState *pcms, int64_t apic_id, Error **errp); +void x86_cpus_init(X86MachineState *pcms, int default_cpu_version); CpuInstanceProperties x86_cpu_index_to_props(MachineState *ms, unsigned cpu_index); int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx); @@ -86,6 +87,10 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineSt= ate *ms); =20 void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw); =20 -void x86_load_linux(PCMachineState *pcms, FWCfgState *fw_cfg); +void x86_load_linux(X86MachineState *x86ms, + FWCfgState *fw_cfg, + int acpi_data_size, + bool pvh_enabled, + bool linuxboot_dma_enabled); =20 #endif --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930573; cv=none; d=zoho.com; s=zohoarc; b=B8L68gbxVqJthtponf88YpbigrQeEZLM6MdzCTxbXso6DlISX7aWwWhqfPTbYOqvnQ6bPCd03ZA2APKMIeg1WuJ5NYiv6R1njDyf0VGgpT+oR0uOI4ngEdAQfwbMGFgvZ6xi2rLHeGDKrHnWiB73SBCqC4jFwWE6RmZaLMu9bRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930573; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nbdM4QsVX6w/vZF6SHA0C1caqBfc8BftNTLt4pHDGbQ=; b=Ch+PGdUO7Ge2VevRYHhhHxg8a0lraWSXmy62FuVlYu5pOV4E9GZTBv361zxOvO3bxLrjxVCbx6sdc7+VIgTFuR4qksUDblufinTZc2E8i2wQwhfpWh+rBAyVUclP8yY678f/8i0fB3H3uQ1V8CQWw91bpIUTrIAsMGgXpnoQ0Qo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930573173813.5919053563886; Thu, 24 Oct 2019 08:22:53 -0700 (PDT) Received: from localhost ([::1]:45302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNewp-0005OE-Nk for importer@patchew.org; Thu, 24 Oct 2019 11:22:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34825) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiy-0007ry-Lh for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdit-0007ih-At for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:53281) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdir-0007hQ-OI for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:18 -0400 Received: by mail-wm1-x32a.google.com with SMTP id n7so2166733wmc.3 for ; Thu, 24 Oct 2019 07:04:16 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nbdM4QsVX6w/vZF6SHA0C1caqBfc8BftNTLt4pHDGbQ=; b=d6heQ/OBpiVsx1ecilCPT+HUeoAdccwTZUdXs0eAT//BB9MAAL3NzqsWe8p/rFAwkm 4gNQWW4N2VL5S8CpmYZqjdAiJGbt6RYyqZQZqI20oiL0YAqClvyVRwHU1rbl7voyX8RL fMWh2w1LvvYVZtF+C8G6N/DiXHC/lZIFamSNcZmlaOA4kqn0NxONoJynF5IuaQD/IHaP JfQi5apBa/8GZdf0PuUnm3AI8TzceISZ7AbyXSDbE9Tp12lIGZoXvIrETsPF/pm5XJzj 8EQXB1iELmwVJiZ6c1T8cYPClSa6E4s3zBF+LNYUzv62qqKlcEGH0Yic2WxrUdLRCSdt bOjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nbdM4QsVX6w/vZF6SHA0C1caqBfc8BftNTLt4pHDGbQ=; b=FGyVzSqzuSCQxWmv+QKCmBw/tSyYVA84WR9aKpO2MI2UjE+jvGv9wH1EqPjtq9OciT bIfD5jRGeIjS4Etbu0MPp7rRsV17TjJwTXYSnaY/ksjrNIT+ZyoMRexPnPi+WMwTsZq5 tEwoQjcPLGNZSQ7MfVamNhNUtf2GWcL8Gb/JfjFaWyadlSWd4SSqMPcLxeeax15nH4ZI Ubk3mQO6MdjUVMe1p891CSkPinoo5wPX7jyXb1XZVWcMsPzDYGx0mqFAIkMN74eMPHe0 gfTEaUmECx73/ZwORlY0tqiwbTUpqSF59bCTlGbGdHI/SRrK3BcbHbGtlccZBhUUksIR ZI7Q== X-Gm-Message-State: APjAAAU7pu0wZob2cJRLZuiVXkO9dAneVtoz0zkrQUvLKalEwCqMQX4J 1NSrPWE8Qm8udkDUvbvLZBhCQbzr X-Google-Smtp-Source: APXvYqw7/VeX3i9cgxJ9iiNHwbF3RFDBrDwZ222FLJnkpUPZHsdovMjryKNglHUFm7zPnz9QkrJTSg== X-Received: by 2002:a1c:6386:: with SMTP id x128mr4994980wmb.41.1571925855227; Thu, 24 Oct 2019 07:04:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/39] fw_cfg: add "modify" functions for all types Date: Thu, 24 Oct 2019 16:03:32 +0200 Message-Id: <1571925835-31930-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez This allows to alter the contents of an already added item. Signed-off-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/nvram/fw_cfg.c | 29 +++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7dc3ac3..aef1727 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -690,6 +690,15 @@ void fw_cfg_add_string(FWCfgState *s, uint16_t key, co= nst char *value) fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz); } =20 +void fw_cfg_modify_string(FWCfgState *s, uint16_t key, const char *value) +{ + size_t sz =3D strlen(value) + 1; + char *old; + + old =3D fw_cfg_modify_bytes_read(s, key, g_memdup(value, sz), sz); + g_free(old); +} + void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value) { uint16_t *copy; @@ -720,6 +729,16 @@ void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint3= 2_t value) fw_cfg_add_bytes(s, key, copy, sizeof(value)); } =20 +void fw_cfg_modify_i32(FWCfgState *s, uint16_t key, uint32_t value) +{ + uint32_t *copy, *old; + + copy =3D g_malloc(sizeof(value)); + *copy =3D cpu_to_le32(value); + old =3D fw_cfg_modify_bytes_read(s, key, copy, sizeof(value)); + g_free(old); +} + void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value) { uint64_t *copy; @@ -730,6 +749,16 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint6= 4_t value) fw_cfg_add_bytes(s, key, copy, sizeof(value)); } =20 +void fw_cfg_modify_i64(FWCfgState *s, uint16_t key, uint64_t value) +{ + uint64_t *copy, *old; + + copy =3D g_malloc(sizeof(value)); + *copy =3D cpu_to_le64(value); + old =3D fw_cfg_modify_bytes_read(s, key, copy, sizeof(value)); + g_free(old); +} + void fw_cfg_set_order_override(FWCfgState *s, int order) { assert(s->fw_cfg_order_override =3D=3D 0); diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 80e435d..b5291ee 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -99,6 +99,20 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void = *data, size_t len); void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value); =20 /** + * fw_cfg_modify_string: + * @s: fw_cfg device being modified + * @key: selector key value for new fw_cfg item + * @value: NUL-terminated ascii string + * + * Replace the fw_cfg item available by selecting the given key. The new + * data will consist of a dynamically allocated copy of the provided strin= g, + * including its NUL terminator. The data being replaced, assumed to have + * been dynamically allocated during an earlier call to either + * fw_cfg_add_string() or fw_cfg_modify_string(), is freed before returnin= g. + */ +void fw_cfg_modify_string(FWCfgState *s, uint16_t key, const char *value); + +/** * fw_cfg_add_i16: * @s: fw_cfg device being modified * @key: selector key value for new fw_cfg item @@ -137,6 +151,20 @@ void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, ui= nt16_t value); void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value); =20 /** + * fw_cfg_modify_i32: + * @s: fw_cfg device being modified + * @key: selector key value for new fw_cfg item + * @value: 32-bit integer + * + * Replace the fw_cfg item available by selecting the given key. The new + * data will consist of a dynamically allocated copy of the given 32-bit + * value, converted to little-endian representation. The data being replac= ed, + * assumed to have been dynamically allocated during an earlier call to + * either fw_cfg_add_i32() or fw_cfg_modify_i32(), is freed before returni= ng. + */ +void fw_cfg_modify_i32(FWCfgState *s, uint16_t key, uint32_t value); + +/** * fw_cfg_add_i64: * @s: fw_cfg device being modified * @key: selector key value for new fw_cfg item @@ -149,6 +177,20 @@ void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint3= 2_t value); void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value); =20 /** + * fw_cfg_modify_i64: + * @s: fw_cfg device being modified + * @key: selector key value for new fw_cfg item + * @value: 64-bit integer + * + * Replace the fw_cfg item available by selecting the given key. The new + * data will consist of a dynamically allocated copy of the given 64-bit + * value, converted to little-endian representation. The data being replac= ed, + * assumed to have been dynamically allocated during an earlier call to + * either fw_cfg_add_i64() or fw_cfg_modify_i64(), is freed before returni= ng. + */ +void fw_cfg_modify_i64(FWCfgState *s, uint16_t key, uint64_t value); + +/** * fw_cfg_add_file: * @s: fw_cfg device being modified * @filename: name of new fw_cfg file item --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928183; cv=none; d=zoho.com; s=zohoarc; b=lkbVSUhhij0jrZd/LcuDkT9CgpszvtjUjJEfYPmss+ePQdVgp5hxbPt0GVxWWHu3Q789HdP4+R1caixuKpLZaktu2xGb+BVy9V7T3GqAPr9ZvJQf1hJG2K0yzalFmTL+zvF2JGr53wal4JubS2o5zqe+wYTZqd074XbXOYTVIRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928183; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jH2nwRqgKYa3R0rTBZTn8Xjzb4Jj1RuEeZP/EBmAFOQ=; b=PTZJlJOT/VWsKd88arVeuqUxnOAZJW0NGEwLfiwQVp+D0viDnBe0TPV9qh9AbzTKGikrqE1cTey33zLmvhw3fxLCfV+NHgQoGivVMF0GbvsJolF/57Mw/d6+v3h1vhXwabLGarPwuja53U04hhZm547bcZP7NwthD5AVfI4jGKQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928183241330.4117419754374; Thu, 24 Oct 2019 07:43:03 -0700 (PDT) Received: from localhost ([::1]:44478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeKK-0006We-SE for importer@patchew.org; Thu, 24 Oct 2019 10:43:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34752) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiu-0007kI-L6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdit-0007iy-HP for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:20 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:37250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdit-0007hc-59 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: by mail-wm1-x329.google.com with SMTP id q130so2569763wme.2 for ; Thu, 24 Oct 2019 07:04:17 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jH2nwRqgKYa3R0rTBZTn8Xjzb4Jj1RuEeZP/EBmAFOQ=; b=ttWmgb69jGz6z5QeF+0pebo2cZ6OwLadDJYH6MVcSNs/aPgl9tPpoYyh6+LEGFZozD bwiamZoxfVu4NnjcMnzn531fBuf+Fw0v+H6ErrnyMACYzaLyQ1mzgRWdjEWFloxHnt/d mvMtBBWDszt69CYRKT8KL7DNi7W3cqU+HElPsLSM9Q5DEf/7Xzc+D4WaxiujfTrooR2p ROVRW1HYb1bTYvDFyTDvtTrIAFboIM0Pi7CQzaUy9tv8I4/LBHMC8d/fiEKxo/b03tWA vKYpkCmSW+XlVXOXjYt8lQOXW+9Dc74aD03evInhckEAq6twtW2XxCbYeq13I85O7KOQ QWXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jH2nwRqgKYa3R0rTBZTn8Xjzb4Jj1RuEeZP/EBmAFOQ=; b=YGBdU54p9Wc1hO6RTso90ljB36HRJBKRoGueBtmDp1XRCejFhkCtj9R8BJQNN2+Fxk ZaZRXplIOs+a0RsBGTYI2zfNauBtNP2Z1uZ4f3BIwcAvgyT2AWULKzEyXFGFdOYdeybp ti7QihfUOXytkKX/TOTknai3duIeGQ5y0Ghs1agyOg1A4lr3vmuxffzIIOI8lTVcNJIO R/SP/Fz6RBVa6ycfBVYJo0i5eR7GJAHcsUdMrq/ZQFKGDhDstNpkAfVT0Z7LGyc4CvQa hlpMbhX7ebt18CoLbJEloJrlRk1r9oacQqnTZZqpDahOpc0YTPmkOnwgbjVWnB6QLQQy hAIQ== X-Gm-Message-State: APjAAAXYuh/h6EyAv8GdtyKkpXtuWStLIpqLaUPUvYPemJ5y/wtx71jd i8Phdxy73ERaMRhbWw1tWtNzfNGn X-Google-Smtp-Source: APXvYqzxsM5TBXTsSUza+KaQ68RXiGu+M6DI8KdwDaR47CCDCVzUBM/iFuxTG6Do/BwABWDAPi30zg== X-Received: by 2002:a7b:cd19:: with SMTP id f25mr5365027wmj.154.1571925856561; Thu, 24 Oct 2019 07:04:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 17/39] hw/intc/apic: reject pic ints if isa_pic == NULL Date: Thu, 24 Oct 2019 16:03:33 +0200 Message-Id: <1571925835-31930-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sergio Lopez In apic_accept_pic_intr(), reject PIC interruptions if a i8259 PIC has not been instantiated (isa_pic =3D=3D NULL). Suggested-by: Paolo Bonzini Signed-off-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin --- hw/intc/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index bce8991..2a74f7b 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -610,7 +610,7 @@ int apic_accept_pic_intr(DeviceState *dev) =20 if ((s->apicbase & MSR_IA32_APICBASE_ENABLE) =3D=3D 0 || (lvt0 & APIC_LVT_MASKED) =3D=3D 0) - return 1; + return isa_pic !=3D NULL; =20 return 0; } --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928634; cv=none; d=zoho.com; s=zohoarc; b=mLbn04X1bDIS8fS3YM82FZ3j5Nu6/1VjQYMi7+XTEx5tpsaomsuUdJFARV5UU7qvreVsRmPfy1syFLHAFr84m7VaEmQEhCOwwaN8kTLKpPYf0KgYVZzpn2P7Lijv83raHWZoCk2HC1EKrgtR3/AS2dBfuqiqWqWp3IR1HN1aeKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928634; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jIVTluwWuLglCq7FAhl2QTjrxUZZpA+vOdu0cwQeY70=; b=J3MDUDRnZih/l+ZUPMUC5+qW3Vt9J2cWv2zootyjzGz/GEaN9KAXnec2D/nMPn3ugHKVJk+K5s6iWPj53HungCE+lGIislCSVtOISF3fD8y53m8m57Dhx4ySt2D3UKUw2PMsUUSnscmzeSsNuzX3/mj3kCBG8ixlJWfFes5FmhY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928634212903.5823779286236; Thu, 24 Oct 2019 07:50:34 -0700 (PDT) Received: from localhost ([::1]:44608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeRc-0004hQ-3b for importer@patchew.org; Thu, 24 Oct 2019 10:50:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiw-0007nO-6w for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdit-0007jA-Nu for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:22 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdit-0007iJ-G6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:19 -0400 Received: by mail-wm1-x343.google.com with SMTP id r141so2731875wme.4 for ; Thu, 24 Oct 2019 07:04:19 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jIVTluwWuLglCq7FAhl2QTjrxUZZpA+vOdu0cwQeY70=; b=NdFktVUlW60Y8hhbi8ybE+VaxsWIeadYt8LcwoVY/giH4hjhTcykrIsE+2iqemdgsa QQpttqstps7DUcTFPh7j63W3oNm4rVGT6lDKDKk7wTm1C0z7RVNf+DMhJVUuTf3tipN6 hOVqEiI1W5KRe7eSzuaaDMKJkWfNKjrLa5IsrYIM4XQvhpx0OUZMaeAt3Az6j327Pkpn jns5qlGuTr6LDqufG5y2ChBUfbl6ZslVizR/Y905CWSViw5Tt91YEmNte8pviP3G3TQv UCGB7VtijG3Jp8jXDFt+OYXNKCwkjgcX2Y3cMIQjJ8X6ktkVpsqMIRMFxthAh1QPt8Zu M+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jIVTluwWuLglCq7FAhl2QTjrxUZZpA+vOdu0cwQeY70=; b=n+xjqR1PZCfOrl6ZLcaMh22Ta4PMjNo3QqadbIcHVQsqzaGkmGjfEPoAtxI/A7peN0 DnrCrJp5HI5knktfUKK5T0uTMoyyO0TVklS4T1ayrvLozI4VAH/1nSuF76tuUyTZJ3fH ZJhh7gidViVIQSyfCGbmo26AnGNqXzohS5RBi6gw7RioyiVRnoOFlWDGrkxBWT5lQDbX cSuDGVRM/Pgkc4wxfvzEvF4TrkLNqQz52EIwTwh+Q5LeERZOXqujqKhPSliWdq26C4XO 2HEYozL4jW9YRaqFk2+7tL/RqJkCfUuHanX6jXPAiIbU1dfCZs/P0a/8bbnfDC4GlA7f LRGw== X-Gm-Message-State: APjAAAV3HOAI8UnOpTWE0oPY8Xi07EPxudccCLKRuu6FFT+Vkd79arvY 1xwCbVZjphfANCQ0oI5D9oAKzz9e X-Google-Smtp-Source: APXvYqwyx2rbmlgjuxYH+mnHr1TyDE2arAZ1MKdKvQ04Ss+J484O1V+xS+RFIe3FyPaIPT7xpCV5VQ== X-Received: by 2002:a1c:398b:: with SMTP id g133mr5413641wma.130.1571925857537; Thu, 24 Oct 2019 07:04:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 18/39] roms: add microvm-bios (qboot) as binary and git submodule Date: Thu, 24 Oct 2019 16:03:34 +0200 Message-Id: <1571925835-31930-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sergio Lopez qboot is a minimalist x86 firmware for booting Linux kernels. It does the mininum amount of work required for the task, and it's able to boot both PVH images and bzImages without relying on option roms. This characteristics make it an ideal companion for the microvm machine type. Signed-off-by: Sergio Lopez Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin --- .gitmodules | 3 +++ pc-bios/bios-microvm.bin | Bin 0 -> 65536 bytes roms/Makefile | 6 ++++++ roms/qboot | 1 + 4 files changed, 10 insertions(+) create mode 100644 pc-bios/bios-microvm.bin create mode 160000 roms/qboot diff --git a/.gitmodules b/.gitmodules index c5c4741..19792c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -58,3 +58,6 @@ [submodule "roms/opensbi"] path =3D roms/opensbi url =3D https://git.qemu.org/git/opensbi.git +[submodule "roms/qboot"] + path =3D roms/qboot + url =3D https://github.com/bonzini/qboot diff --git a/pc-bios/bios-microvm.bin b/pc-bios/bios-microvm.bin new file mode 100644 index 0000000000000000000000000000000000000000..45eabc516692e2d134bbb630d13= 3c7c2dcc9a9b6 GIT binary patch literal 65536 zcmeI2eS8zwneS)hF_vth5y2#;brv;O^x_6mtAUMO%tn5}IEf)jY``G|XbMBqa_^-@ zBBUXSyplo3+VMx9Ci}VFwz~@rx!t?By&v!0UdNb=3DVGyaU`%sJ0_&U3!!Ij`fT?33lo8bTirhX$S6(dmK^Nu2qLAPZJO zd+n=3D&@XLYwWFdS~Zh2c2gidFUEU-}gkOUzx)FqJ6 z;W433mmmmAY+Noh;tibd?18@VxCH}v4GeX#`0DNc_4sRW0TC1A zmJsrGlX|tHBmSvHZ7h?b^=3D>;mu1$tb(P>mvG{5}(=3D7p;C?X{{UgF+=3Dc4I zP{`<|^mTPhV|UNEdEHc{)HAxSYaiW>P|0;&C$X5aR9UVpQyP@Vl`hhv$gdx{Z+-NR zwvW~;(eFuX@wtUs8?fTZ0 z-^y7ZnXZ(N2F|Wml7g>taRZ)SYa#R~3)d_2XS+8|g~IPiN|W-WvPxO4Jf$R*7zq(M zVPZ7&u2-7NT$&*G^Vf&!N<}4sxYR-&zO@e~z~qj%l+aa&|1SJK8kh_(z79nsokwAD^1AC7pf@Oj~FIF9# zF9b$C2U-gqk-~z?@R7iuo?L~z4ZVWkIiSQ^i}NGJ*2?fn#8cjeR;%3om9j(r$>}0* zmHG01U~>3C;Jl}&R|!j%@?|5s#Espmjtu)+#k%inqSKe2u4Y^$dyZBy&S@?QTm*4Jv!DYIMrLsd*G z=3D`T-i{>XEL^*_04^-~G9FB2d;TMqbVppb+**NV)Wh3cyEi~fAMBS-GYFX{6SqmnR3 zi7j8o-YehtBPZl-;$fEDRenBjZPn_8`k0QW%duAboe{h9;n1k=3DPmPBITKXgysm0cG zff9plWlq19^_3qFT=3Deu943;%0F}d3r9Ci6~gQK=3DUjyF9V9G&A|6db+Rf1l@a_=3Dw-< zIgp;B+L?Gjt)J5Gg)}0q>Wcp0HQVM-TQ2)8SKeoRFckXbZl8$MyIG&-ayp6njK|qn zUpF;;x*hu7L6uw4aN!=3Dm!{{NE=3DUSzLa8KY0G!Yj<9~vxX3HENZ(Onw#yXUrCeraCo zVgU^`gK6GqgVb`wZ;#Gbmy2v_MAjdX^lEFX6)k+K<#J$AXn(Om8@eKmZkcJ?-+r#^ zCA}?|Tk-m02jZiTNML7=3D=3DD)CNvx3sYjI-Lq-*XZa2UU;-+c$WsKoy6%2oD<>eine z!#Ejf&|7)}XW?0sdUNKePg&pstJ#T?3+&za*%{)yhd+P##k*mz+)*)!?YnZKwSKA| zu}@-GBM5lQwXLUnbA-^KRrkB=3D>1G$AHSS_ujsr9%IKnN3NV_f2z%xyG&<)WQp>tn@_V;6awYf z{q=3D0PWP~N+=3D^0|;@HO^_x)<+6Z;;S0r?eL5MGEsG)4dPD(&64oU$Ar(mKJI91WQp* z*fzBkMi!_#i^;Q2JgahPiGQ8gvStZuJR~ zt#rF1Q*=3Db?$N+zvO5*<=3D;%c=3DB9T?OE0Z$h_QD(6#I65=3DXr9N+IZ4eRkS9#6`N53nF zgGh%{`-7vUa`;ocs8#P&SmkZ6Ac(#qhoeSdgWU2t0t?xQx ztJi2*MGFO0nhpzHsS48`Vp6I$SzypCIQ|r)66h+xi_VhantBb5r^GsquKknX=3D-R+M zR5)+3-109(YL#R<<}5hotld~R3DG;%8uwi7=3Dx5}ePWAz;ei|y+wczL$|D53HM*s5Q z=3D%zrc`r^c_nOvX1R?2lfbszGepq#~lx-UxZrlnOz{2p{&Q(UKz(M1ePy8b6tOokmV zLn9Qdcp}|RixRp+gLWhp+axvgJlad?eTee+@?{jXu zfYy+<4a9q#+Xg%bFc#Lkt?+6)8^}a<6=3D7{Pl(xY4C3hw+G;lp|9;H5+Abs%xXQ(ef zlf)pDipQPXQqUx2%7Egdw^JoenzQOp1R=3DJ}G z#oOYxtAp`@B3qnI9t8DHEcgY=3DVF>p@4)U7qZI&7f#y_FB9^0F2j)oj89X~b6STSQI zJGB67=3D8qA3IhV9q{PWleZJ*%`FMcgLjZ#$m)L7J#t+PdmS4q~;K5zNqKq{1(6=3DGPR zzt1jQ+&}|ddcP9G9Na5+7s=3DgK*0Mxk2BxTKvC!2A{4?b4l@75|?ykwFgh^OnXr7ZL z33i+&JdDZR31b~%GO@GXorc9VZcG&~Hp$(SA~o)u=3DmIh;l(c%zVi2>ct4HK+8P1VY z))%OjyZbRz-UVHukq7*D$=3D!{UL`<^vIo7g+DDMc$J5q8GgR;CZl=3DRNu;Fbd2d(lC4 zriJ#~jnN$*YE7SvVGH7y;{%g&a;dneK=3D#pEW<1I(by1@!Ly6_^4fgx76!~?plm%+n z5{9EYS7Y6gk?*3`y|@8xwK@?azsl16k9t%NY`T@Nl08`i3bYI6;DEBwPKPHJZrYud zoU9dPO@-cD*-GuwJh;JyN!V~#+6S;vWoVD#t|#DT!#BC>`HZ{PyBj;gRfXAAGOT^wY+@zX`N53g(TAO^u5eMPrzo_quzVwk?s9XOZ#u`Wf%1iwZW^pj&5Bay_-h4&?!svD7EzF;^s5-#C%kdOM#Y? za@Yk<+8fAV&^B6`nhQ&_8YH*uMTN7?oyxijCbmWhc*lVK22!2VV6WNICN4;=3D#ENPf zBHT7SIiG;A!)*l2Phb~}x8987b92)D_ZSoaU%3bdVOzo&{{{O9OoL)L>`+Wn!p z#QN3ZzZ5U3#V4ZW(Pt!9hI5eUbJplHcDBXJzGsg<=3DVV))p?D$OxjYd#!KTeJY?z&~ zfz2yL=3Ds!A+^!Xn!dcxQkGNBI)$4@(L=3Dh^RU*E49yoIC59*PBRXEDujoIhOBniwe>5W9{HXg z<;*qm=3DHa%JZHcy1ZRxh7>{uw_YVawZlM2o+JVz9du6WKKYVQ0xe6?=3Dvj~e8b9^|0; z>oFzzQ}W>GJQ}vt7j=3Df?u;y#JC~w~hkuG6}O}N)r6#8fwn`OJZ868i5U~}$ndO*%% zk;7}@H#p&{dGJ+*`D(ib^ude<8&a@8wFyz53;WeD?Nv(-XAWBru?UW11Qzq+SMG>S z!-IrAfROsI82`}5>YUNK;*!G{16h+D4z&?}B(;kxjNw3u(fZ?Za31oBflXhq)U<5d zBe2r2$2211gXny_dvgwI!eaG!>kZDuZ#(1#i@a?qz=3D4cjF9Ph?ZS^EoxCBfo5*W#(xICY8?vDl{f1nn!9n&<6< zv)Q`-&R=3D6X(U$xP-rTDlqDLY$5G>h`BRqR_UB9~Sk~xlJb^H+<*4~9gJe}wNn3fjt zQ+evv;tKY{TPzW+-X9vV_&3Sh$rrFY+}BzyMHU{zc}#VmcJ7j){|BT$9=3DeW`@gUrc zjfQmRrrgYU6@1~Cg)KfNho>M(n*|6s7?b|57cL%Md<Hx1Orywv z+FD&f1wCJ;ZtBB^;IC0uw6KNpv88?ForP4^u=3DdP&0>xg3o#JS6;Q*dOa^c7HkUJJ0 zQ(qXsF=3DPDVu4tgoqlPrUhKrUNj>c(e|dX3&vva7^I^n zyjNWyk<4}Dm#!2Y1EC)tN$=3D8zFo?l_XiTBCzjdad>-cnmo~(X9uX_Z?_c7Kt^E2eK z9iNQfAiFRmcN}g$_!*Mg?>|>r{&wI4Hgbam8<9KuGcu*;GX0*)*i9Nc4Lt{k_K*&C z;_QNL!3XY;!)~+@f;}aE8%`qWSX7CCc@AEV8=3Dc6--h<0+c`uzQUa^%_Ra-Y{0eBLs$Cy9f*$ zF<;E}3$dX^Nk)L!Fb%aVFvyJ6GHAZHi%``W%O+xxPYC)mi8iR&{RFC+8ZrEb9rW}V z`@)ojTG4rQ!=3DCZxJu$S~Xx@X=3Dykl)j`_Jw*Iy!5}-1betc|rhY(S zEcgzZA){m@O+SYpJ1m=3Dy!_Q)>y%^exYRcjNftpg#Du;iCAd)5A_Ee71uBZn#EmVHz zFd@7!gcwXdM$9EzT^ccl6_D9DCIiZbjNg<&y$azA&W-*&Jf{3G(A<2;n>Bs6fUbel zN7_t~`36STrwo}Uwmbz>;5)&sZhRJwtiW3=3DgtoF$gO#IE<(5ivO04wmgUnZPw7v&5 zp<4fvTn2~5#cUpVP3ztNgx{9S=3DEy8})VrtW;6#u0!Br+3b$GLj+#%CogsVDY_W^%Gq$AZJ!d^I0O%5r!e zeD2vz%~!3)+jhJ)U$r3|crd!LIO>(gCbkRB9~pC5zcH7Y2C?DLfMv2VSnX5J%CGmZ zYHR6PR?vh~yymN-p>hZ8SDUXdp_yOY{7~uH;M>itAib#hs@+KcHPV}}PNpK~Pbe?i zP<)F5qt(_fDsCwKQ&O~z6@(s{Et*ccpM3QW&>K|NMI}^Ahde1Z#9k%5OU&HOhHlFOKF}Se7{^O zi2VzjKd02d`B}O7cy<-y$N1ntyWxxfE165FzUsxk-rPG8l9IVacsy41=3D%Y9XK&a8> za&@{8=3D>8ZB=3DiL~_@LwDkUrXlBMVufET<^qD$Bm~s6Hc$jcCsG~GMxVu87JfNFKt(_ zTa()!L^E~!pvj}tbOTK^xL9$fKf>N+e~hWi29vcT6rHRkrxki@2ZczL*jr^O!~!qe z2siJo$`RR*CH8%*y5y|qi05QF7j>UfDIP8VUEs2~(k*#Iy@lnHJMb^~?qrQhZnZcV zKV?z(RG?t>Uu*CiO4KXKJW)t4vOLsK=3D~9x5Cb?Yrgo?vy!(beIOLDiRN{pBPK5!W$ zEdDW}cao)5a(g3^J5nnu$y!UHX#96b&vkW~80xilqHg$>o6f^HlF9pC;Ib;om<^>) z3z&cMtgSN4u^euyssPTN%+kJ2}SK9=3D+xQA5M^<~khAvsVdWq>ur#;6Bu5%IZ0t+rzO;df!Z8#MHfrhlo# zz%(cID>xx+@Ac+c(!V8i$q;FhpvkBxhJ%-FMginQoz!|0I6=3DS3DH)<uM-rRoLC+t2igf`Y|;Ad({_=3Dsc^6xzT-L>nK(g_#I(CG(V;*TE}#I08Gt9D6>K&20HSUL!oPU`wj5~y-m zTP#%$`}UkFhjW`$2!a=3DKVaU-3KeIl|jf#+tm6^0H z2;Yt~=3D^)O>pyO^lO&u@=3DynJ{q!+jiS#y=3Ds!j+^RT?I?W#Zc}+fRci_?>u!!k+d<#o z;I8;U*Z&nyD(@CLy_SHZuEtSc>(G-gGq8I9Ap;)-*VLYqH@b4qsz7jQEH1voDW3 zR#rNis?e6y2D?zMHlXV+goSE{bCILC(&1{PrVwW1-k(Wtpmf+3veY_m*RI+AWB*Xs zDL-8<+|++QLmAYzrjBZK{Dkmx-I7DQCL{eAeWfovymzF*9JY+zQzy2HS5DRs+s~MszfA78 zkjwfj`3d>!F2qe9>x)&iRW`00>oga!RHyKuu0Kr@x8h=3D1al=3DSuj!BIWZ%4ilh{dh) zegDScy}BSr7H^ECu565%yYTd$({(!DG27i3zcF8gB${z2%O{UNQgZe>fg z!3qy_x650R$s4<<>(#fn-?h&F-EXcd`&Ow?x<#O{|2t1_ST|?GfBVkbbw3gwZ>Vwk z8XtE-7r!_GPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(8 z6W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;Z zH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULas zfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O z1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1U zPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu z-~>1UPJk2O1ULasfD_;ZH~~(86W|0m0ZxDu-~>1UPJk2O1ULasfD_;ZH~~(86W|0m z0Z!od1Ux-$$J=3D_^2HLc?{{JUzm0dl`OkLOi(JspO^xUV&;+-j7IrD2oSp}ujDU3^> o5d@0NUb>FZ&)-2Do-dnE`R8)xT^9bc5QmajO4XIv_+RY*0|l%Fi~s-t literal 0 HcmV?d00001 diff --git a/roms/Makefile b/roms/Makefile index da4efa4..c150170 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -67,6 +67,7 @@ default help: @echo " opensbi32-virt -- update OpenSBI for 32-bit virt machine" @echo " opensbi64-virt -- update OpenSBI for 64-bit virt machine" @echo " opensbi64-sifive_u -- update OpenSBI for 64-bit sifive_u machine" + @echo " bios-microvm -- update bios-microvm.bin (qboot)" @echo " clean -- delete the files generated by the previous= " \ "build targets" =20 @@ -186,6 +187,10 @@ opensbi64-sifive_u: PLATFORM=3D"sifive/fu540" cp opensbi/build/platform/sifive/fu540/firmware/fw_jump.bin ../pc-bios/op= ensbi-riscv64-sifive_u-fw_jump.bin =20 +bios-microvm: + $(MAKE) -C qboot + cp qboot/bios.bin ../pc-bios/bios-microvm.bin + clean: rm -rf seabios/.config seabios/out seabios/builds $(MAKE) -C sgabios clean @@ -198,3 +203,4 @@ clean: $(MAKE) -C skiboot clean $(MAKE) -f Makefile.edk2 clean $(MAKE) -C opensbi clean + $(MAKE) -C qboot clean diff --git a/roms/qboot b/roms/qboot new file mode 160000 index 0000000..cb1c49e --- /dev/null +++ b/roms/qboot @@ -0,0 +1 @@ +Subproject commit cb1c49e0cfac99b9961d136ac0194da62c28cf64 --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931342; cv=none; d=zoho.com; s=zohoarc; b=FOGecfkmV24uDoMkcsFpKK2TOlNd6Db21zD3HxPQxQoTtT3F0ud31zFKycuF5eAil6PLOmp7c9cn0vIEIA+V+z0DcqbKf0a/MyG9/auP+5D40jWmkLlI6/n+bxrR7d+a09PQ2yY4hlF/tyXbHLa0U4vAtVyJ/Pvvnm9qfsiQwbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I9JsqJ1MLvuD5qQCxsE/vI2P7L8FB/WYGzzDrDXMd7I=; b=Cm+dMUw2JZx9uLur6L02vLHYwy/JegKUNIIL112MV47EupJvbHI3fEdCzzrV8tGs1M9OBDMXIrwueO3l0eqqfE4shOwbKsp0YbOt/NvfJPhYkF2Eer8STd6d2vVHrtAtGyffe4WwDtXWt5Yximv/cJUvglCgnDgBYkrR4L6t2Gg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931342159792.3538942746821; Thu, 24 Oct 2019 08:35:42 -0700 (PDT) Received: from localhost ([::1]:45476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf9I-0003ZJ-Pl for importer@patchew.org; Thu, 24 Oct 2019 11:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiz-0007tn-PZ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiu-0007jT-Bj for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:25 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36913) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdiu-0007il-4k for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:20 -0400 Received: by mail-wm1-x342.google.com with SMTP id q130so2569881wme.2 for ; Thu, 24 Oct 2019 07:04:19 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I9JsqJ1MLvuD5qQCxsE/vI2P7L8FB/WYGzzDrDXMd7I=; b=JP5Q6fx1YrRB6ChMMcZCCZ5fOjoWBV7f4/M6bWUaW8D3M0wNF0JuUf6LoHXt4UvIU8 u82cnIEvXjyV+pqemUcvWo9xG5b5lBFaDu4gWHpp9RHrnkONVM5LLZIH7QIbft3/S7Du I0Bh2ztLNTr4w2FD5w+rEp3/w+69TC7cjw4k+UnIbDuydztDb1VEQ76EExgz2R+X1f8a ppTkgHrPFBCffzKRpWRT57X47L57NvXTSEAEJNTMb2ohsU6Pt1PUe4/PhM+EKMbRDPTN XS9mfZM5A4F8VOUtv0bkHa/+vFsSM5Dit13uWpHKi06/PuAxbdQgGMVOQ8i5g4HkKWGo GK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=I9JsqJ1MLvuD5qQCxsE/vI2P7L8FB/WYGzzDrDXMd7I=; b=Ebon9oncuvTIe2ZURp6UuhaXNSmy+lRmj4jP4t/tgn/KT20PMe/DYfmoZCYC/nMNs/ +b0eGqG8Wd+G1DrSMT1SdgEMttxwO2IjWaABQJLciRQXynKL1SsRKRthDvW6wWlXjHj6 +auAwy+UQlGm0YR6aZr9oy+0wtJcQPDWKppcl0M9rDjZ9ihNn65tLLdclSndvkvFyOg9 L7WwxLSmcsdQPcl0ZL/SmRD5bQ4gNXb8aVy6ypYWS4lulLYbk/lycc+8beKQ769/s6a9 8MH/qQbvriaUpnqypEPdlViOjFzsCLAGTSbWjKKTGPU5ZO+c111bdD/fk0CFQO1r12Sh hF5g== X-Gm-Message-State: APjAAAXB9EWBYFL+01nWtkqXbnH7eWu/e6fMQx23Zk3SClPvI/FawNxY YHc1OP9Zb4/vonVA+XnfSyMg1gL6 X-Google-Smtp-Source: APXvYqzLTlA28o+4ls/bYxiv6g1u1Ofs0WFkewu6HSoLKPQ2OVgyhUPp7NifROiI9UgM75+KXwcflw== X-Received: by 2002:a1c:e404:: with SMTP id b4mr5557560wmh.90.1571925858542; Thu, 24 Oct 2019 07:04:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 19/39] docs/microvm.rst: document the new microvm machine type Date: Thu, 24 Oct 2019 16:03:35 +0200 Message-Id: <1571925835-31930-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Document the new microvm machine type. Signed-off-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Reviewed-by: Marc-Andr=C3=A9 Lureau --- docs/microvm.rst | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 108 insertions(+) create mode 100644 docs/microvm.rst diff --git a/docs/microvm.rst b/docs/microvm.rst new file mode 100644 index 0000000..aae811a --- /dev/null +++ b/docs/microvm.rst @@ -0,0 +1,108 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +microvm Machine Type +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +``microvm`` is a machine type inspired by ``Firecracker`` and +constructed after its machine model. + +It's a minimalist machine type without ``PCI`` nor ``ACPI`` support, +designed for short-lived guests. microvm also establishes a baseline +for benchmarking and optimizing both QEMU and guest operating systems, +since it is optimized for both boot time and footprint. + + +Supported devices +----------------- + +The microvm machine type supports the following devices: + +- ISA bus +- i8259 PIC (optional) +- i8254 PIT (optional) +- MC146818 RTC (optional) +- One ISA serial port (optional) +- LAPIC +- IOAPIC (with kernel-irqchip=3Dsplit by default) +- kvmclock (if using KVM) +- fw_cfg +- Up to eight virtio-mmio devices (configured by the user) + + +Limitations +----------- + +Currently, microvm does *not* support the following features: + + - PCI-only devices. + - Hotplug of any kind. + - Live migration across QEMU versions. + + +Using the microvm machine type +------------------------------ + +Machine-specific options +~~~~~~~~~~~~~~~~~~~~~~~~ + +It supports the following machine-specific options: + +- microvm.x-option-roms=3Dbool (Set off to disable loading option ROMs) +- microvm.pit=3DOnOffAuto (Enable i8254 PIT) +- microvm.isa-serial=3Dbool (Set off to disable the instantiation an ISA s= erial port) +- microvm.pic=3DOnOffAuto (Enable i8259 PIC) +- microvm.rtc=3DOnOffAuto (Enable MC146818 RTC) +- microvm.auto-kernel-cmdline=3Dbool (Set off to disable adding virtio-mmi= o devices to the kernel cmdline) + + +Boot options +~~~~~~~~~~~~ + +By default, microvm uses ``qboot`` as its BIOS, to obtain better boot +times, but it's also compatible with ``SeaBIOS``. + +As no current FW is able to boot from a block device using +``virtio-mmio`` as its transport, a microvm-based VM needs to be run +using a host-side kernel and, optionally, an initrd image. + + +Running a microvm-based VM +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, microvm aims for maximum compatibility, enabling both +legacy and non-legacy devices. In this example, a VM is created +without passing any additional machine-specific option, using the +legacy ``ISA serial`` device as console:: + + $ qemu-system-x86_64 -M microvm \ + -enable-kvm -cpu host -m 512m -smp 2 \ + -kernel vmlinux -append "earlyprintk=3DttyS0 console=3DttyS0 root=3D/= dev/vda" \ + -nodefaults -no-user-config -nographic \ + -serial stdio \ + -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ + -device virtio-blk-device,drive=3Dtest \ + -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -device virtio-net-device,netdev=3Dtap0 + +While the example above works, you might be interested in reducing the +footprint further by disabling some legacy devices. If you're using +``KVM``, you can disable the ``RTC``, making the Guest rely on +``kvmclock`` exclusively. Additionally, if your host's CPUs have the +``TSC_DEADLINE`` feature, you can also disable both the i8259 PIC and +the i8254 PIT (make sure you're also emulating a CPU with such feature +in the guest). + +This is an example of a VM with all optional legacy features +disabled:: + + $ qemu-system-x86_64 \ + -M microvm,x-option-roms=3Doff,pit=3Doff,pic=3Doff,isa-serial=3Doff,r= tc=3Doff \ + -enable-kvm -cpu host -m 512m -smp 2 \ + -kernel vmlinux -append "console=3Dhvc0 root=3D/dev/vda" \ + -nodefaults -no-user-config -nographic \ + -chardev stdio,id=3Dvirtiocon0 \ + -device virtio-serial-device \ + -device virtconsole,chardev=3Dvirtiocon0 \ + -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ + -device virtio-blk-device,drive=3Dtest \ + -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -device virtio-net-device,netdev=3Dtap0 --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930365; cv=none; d=zoho.com; s=zohoarc; b=aizH2MPdyK+GmjURTxK2ZO8hQhGmLc7fV7mgUiBCZ4Y3iC5dROq/7jVatvatfOq2VHbMWbgloB2v7lv4m1jmPf6Xzcmha8BhfV8yfNDGMyp7e9IQIa7kqG+SAYq/WUzErZvvaFF41XlOymeBwg4WLOmukUA/bxbst5gcte/S2cY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930365; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jJ1y0/sR6J/uG3wIU6ScgkkGr/cG4Z8JnvWB/WUkOdE=; b=QdZEluA+nzd3oIlNTsRxXALguyfBySMWUxwUEMRjrC3/lEJBWqTxuiDDHzGdnZ26piCvO8FvymlxiRVtBqE7TrVNTyAel3yayJCAsCDGUClC2/VSnKwHPMJP6OFxhaX8LKXjvU1ZeTg9Zkvv9RkNQ+J6diAHLKNw4r7mhqSOgfQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930365670839.0176418636127; Thu, 24 Oct 2019 08:19:25 -0700 (PDT) Received: from localhost ([::1]:45264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNetX-0000aM-Uo for importer@patchew.org; Thu, 24 Oct 2019 11:19:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34829) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiy-0007sJ-Q6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiv-0007k4-O9 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:55859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdiv-0007jf-D2 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:21 -0400 Received: by mail-wm1-x32b.google.com with SMTP id g24so2984844wmh.5 for ; Thu, 24 Oct 2019 07:04:21 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jJ1y0/sR6J/uG3wIU6ScgkkGr/cG4Z8JnvWB/WUkOdE=; b=CCgCqdUY+t7+0Nnv8GnE268zqOHTRyqz3HSI++WBOmNVRxZBnqK9ak4QsKl3CzLyEo uCz3TvkSSPoZdwGXoYzbf4aLve1qCIig+RR8T2bs2H+kXE06ciXN/vfdcVZtdi3QYlp2 aC6DOCgcZE9adBlumECG7boBxwJLVuyCzWd5rrSPPSBa03fyu6UkbS7mD2vJCnXh0xHu AiSRrTG7oZ89OuOf+1z/AmXrDoPxfY3QVnafnDGGlRiidQ/SJjc7lYMjtbf18F7DK0Tp pXn1kTMxcFgz7yBB0iPtddc2SlecDhCZk1p0SkmSFBkctgPje9olNYNxFUfhhdrjuxCK E+jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jJ1y0/sR6J/uG3wIU6ScgkkGr/cG4Z8JnvWB/WUkOdE=; b=uDQ5FMvL23JuE6FOo86XjuhqI3MjTTcqwDMERqOAqEvU2T3TmW2OtR0lEB77ydEKH3 IiufwzKM5pufz211+KkjIZ4BYX3XK5UVlHYkJNo8P2uw5cJownRAPp9q+LTPPAudgRP7 6yroF3+xDqYNyMxldxlkFVLfQWYQogShqbWvhFQZNWrrA6FuqKAwA7JwE3GQCvIe9myL 140oEzdj5g45V2TTZeIhVDx/KvtbvbM7pIS3lSy3+GuPtFFCZ9PtopPoDNOIaW1lRoVz 1l88tdJGqgjLPK8kRPZYKzxhkFzfvOZhqr2yNE6ZgYwIUnTeRQRwWaqZNFZd2MLGehZp glyQ== X-Gm-Message-State: APjAAAUOdyUazx5rWr9hIddJtf6LJ6J0MOY1H/4hy1lnL20koYtp4fX8 EnbDT324aoF6Gv0SIkgmxFz5a6VY X-Google-Smtp-Source: APXvYqzJsbEVWhsude7TSdBOv+IcxDcQFLmngn2xh1kmivu690Zq0H/0qfNZOzmszdwbBdKwe1meuQ== X-Received: by 2002:a1c:a556:: with SMTP id o83mr5493219wme.0.1571925859708; Thu, 24 Oct 2019 07:04:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/39] hw/i386: Introduce the microvm machine type Date: Thu, 24 Oct 2019 16:03:36 +0200 Message-Id: <1571925835-31930-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sergio Lopez microvm is a machine type inspired by Firecracker and constructed after its machine model. It's a minimalist machine type without PCI nor ACPI support, designed for short-lived guests. microvm also establishes a baseline for benchmarking and optimizing both QEMU and guest operating systems, since it is optimized for both boot time and footprint. Signed-off-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin --- default-configs/i386-softmmu.mak | 1 + hw/i386/Kconfig | 10 + hw/i386/Makefile.objs | 1 + hw/i386/microvm.c | 572 +++++++++++++++++++++++++++++++++++= ++++ include/hw/i386/microvm.h | 71 +++++ 5 files changed, 655 insertions(+) create mode 100644 hw/i386/microvm.c create mode 100644 include/hw/i386/microvm.h diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmm= u.mak index 4229900..4cc64da 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -28,3 +28,4 @@ CONFIG_ISAPC=3Dy CONFIG_I440FX=3Dy CONFIG_Q35=3Dy +CONFIG_MICROVM=3Dy diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index c5c9d49..b25bb6d 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -92,6 +92,16 @@ config Q35 select SMBIOS select FW_CFG_DMA =20 +config MICROVM + bool + imply SERIAL_ISA + select ISA_BUS + select APIC + select IOAPIC + select I8259 + select MC146818RTC + select VIRTIO_MMIO + config VTD bool =20 diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 7ed80a4..0d195b5 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -4,6 +4,7 @@ obj-y +=3D x86.o obj-y +=3D pc.o obj-$(CONFIG_I440FX) +=3D pc_piix.o obj-$(CONFIG_Q35) +=3D pc_q35.o +obj-$(CONFIG_MICROVM) +=3D microvm.o obj-y +=3D fw_cfg.o pc_sysfw.o obj-y +=3D x86-iommu.o obj-$(CONFIG_VTD) +=3D intel_iommu.o diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c new file mode 100644 index 0000000..20d2189 --- /dev/null +++ b/hw/i386/microvm.c @@ -0,0 +1,572 @@ +/* + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/cutils.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "qapi/qapi-visit-common.h" +#include "sysemu/sysemu.h" +#include "sysemu/cpus.h" +#include "sysemu/numa.h" +#include "sysemu/reset.h" + +#include "hw/loader.h" +#include "hw/irq.h" +#include "hw/kvm/clock.h" +#include "hw/i386/microvm.h" +#include "hw/i386/x86.h" +#include "hw/i386/pc.h" +#include "target/i386/cpu.h" +#include "hw/timer/i8254.h" +#include "hw/timer/mc146818rtc.h" +#include "hw/char/serial.h" +#include "hw/i386/topology.h" +#include "hw/i386/e820_memory_layout.h" +#include "hw/i386/fw_cfg.h" +#include "hw/virtio/virtio-mmio.h" + +#include "cpu.h" +#include "elf.h" +#include "kvm_i386.h" +#include "hw/xen/start_info.h" + +#define MICROVM_BIOS_FILENAME "bios-microvm.bin" + +static void microvm_set_rtc(MicrovmMachineState *mms, ISADevice *s) +{ + X86MachineState *x86ms =3D X86_MACHINE(mms); + int val; + + val =3D MIN(x86ms->below_4g_mem_size / KiB, 640); + rtc_set_memory(s, 0x15, val); + rtc_set_memory(s, 0x16, val >> 8); + /* extended memory (next 64MiB) */ + if (x86ms->below_4g_mem_size > 1 * MiB) { + val =3D (x86ms->below_4g_mem_size - 1 * MiB) / KiB; + } else { + val =3D 0; + } + if (val > 65535) { + val =3D 65535; + } + rtc_set_memory(s, 0x17, val); + rtc_set_memory(s, 0x18, val >> 8); + rtc_set_memory(s, 0x30, val); + rtc_set_memory(s, 0x31, val >> 8); + /* memory between 16MiB and 4GiB */ + if (x86ms->below_4g_mem_size > 16 * MiB) { + val =3D (x86ms->below_4g_mem_size - 16 * MiB) / (64 * KiB); + } else { + val =3D 0; + } + if (val > 65535) { + val =3D 65535; + } + rtc_set_memory(s, 0x34, val); + rtc_set_memory(s, 0x35, val >> 8); + /* memory above 4GiB */ + val =3D x86ms->above_4g_mem_size / 65536; + rtc_set_memory(s, 0x5b, val); + rtc_set_memory(s, 0x5c, val >> 8); + rtc_set_memory(s, 0x5d, val >> 16); +} + +static void microvm_gsi_handler(void *opaque, int n, int level) +{ + GSIState *s =3D opaque; + + qemu_set_irq(s->ioapic_irq[n], level); +} + +static void microvm_devices_init(MicrovmMachineState *mms) +{ + X86MachineState *x86ms =3D X86_MACHINE(mms); + ISABus *isa_bus; + ISADevice *rtc_state; + GSIState *gsi_state; + int i; + + /* Core components */ + + gsi_state =3D g_malloc0(sizeof(*gsi_state)); + if (mms->pic =3D=3D ON_OFF_AUTO_ON || mms->pic =3D=3D ON_OFF_AUTO_AUTO= ) { + x86ms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_= PINS); + } else { + x86ms->gsi =3D qemu_allocate_irqs(microvm_gsi_handler, + gsi_state, GSI_NUM_PINS); + } + + isa_bus =3D isa_bus_new(NULL, get_system_memory(), get_system_io(), + &error_abort); + isa_bus_irqs(isa_bus, x86ms->gsi); + + ioapic_init_gsi(gsi_state, "machine"); + + kvmclock_create(); + + for (i =3D 0; i < VIRTIO_NUM_TRANSPORTS; i++) { + sysbus_create_simple("virtio-mmio", + VIRTIO_MMIO_BASE + i * 512, + x86ms->gsi[VIRTIO_IRQ_BASE + i]); + } + + /* Optional and legacy devices */ + + if (mms->pic =3D=3D ON_OFF_AUTO_ON || mms->pic =3D=3D ON_OFF_AUTO_AUTO= ) { + qemu_irq *i8259; + + i8259 =3D i8259_init(isa_bus, pc_allocate_cpu_irq()); + for (i =3D 0; i < ISA_NUM_IRQS; i++) { + gsi_state->i8259_irq[i] =3D i8259[i]; + } + g_free(i8259); + } + + if (mms->pit =3D=3D ON_OFF_AUTO_ON || mms->pit =3D=3D ON_OFF_AUTO_AUTO= ) { + if (kvm_pit_in_kernel()) { + kvm_pit_init(isa_bus, 0x40); + } else { + i8254_pit_init(isa_bus, 0x40, 0, NULL); + } + } + + if (mms->rtc =3D=3D ON_OFF_AUTO_ON || + (mms->rtc =3D=3D ON_OFF_AUTO_AUTO && !kvm_enabled())) { + rtc_state =3D mc146818_rtc_init(isa_bus, 2000, NULL); + microvm_set_rtc(mms, rtc_state); + } + + if (mms->isa_serial) { + serial_hds_isa_init(isa_bus, 0, 1); + } + + if (bios_name =3D=3D NULL) { + bios_name =3D MICROVM_BIOS_FILENAME; + } + x86_bios_rom_init(get_system_memory(), true); +} + +static void microvm_memory_init(MicrovmMachineState *mms) +{ + MachineState *machine =3D MACHINE(mms); + X86MachineState *x86ms =3D X86_MACHINE(mms); + MemoryRegion *ram, *ram_below_4g, *ram_above_4g; + MemoryRegion *system_memory =3D get_system_memory(); + FWCfgState *fw_cfg; + ram_addr_t lowmem; + int i; + + /* + * Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory + * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping + * also known as MMCFG). + * If it doesn't, we need to split it in chunks below and above 4G. + * In any case, try to make sure that guest addresses aligned at + * 1G boundaries get mapped to host addresses aligned at 1G boundaries. + */ + if (machine->ram_size >=3D 0xb0000000) { + lowmem =3D 0x80000000; + } else { + lowmem =3D 0xb0000000; + } + + /* + * Handle the machine opt max-ram-below-4g. It is basically doing + * min(qemu limit, user limit). + */ + if (!x86ms->max_ram_below_4g) { + x86ms->max_ram_below_4g =3D 4 * GiB; + } + if (lowmem > x86ms->max_ram_below_4g) { + lowmem =3D x86ms->max_ram_below_4g; + if (machine->ram_size - lowmem > lowmem && + lowmem & (1 * GiB - 1)) { + warn_report("There is possibly poor performance as the ram siz= e " + " (0x%" PRIx64 ") is more then twice the size of" + " max-ram-below-4g (%"PRIu64") and" + " max-ram-below-4g is not a multiple of 1G.", + (uint64_t)machine->ram_size, x86ms->max_ram_below_= 4g); + } + } + + if (machine->ram_size > lowmem) { + x86ms->above_4g_mem_size =3D machine->ram_size - lowmem; + x86ms->below_4g_mem_size =3D lowmem; + } else { + x86ms->above_4g_mem_size =3D 0; + x86ms->below_4g_mem_size =3D machine->ram_size; + } + + ram =3D g_malloc(sizeof(*ram)); + memory_region_allocate_system_memory(ram, NULL, "microvm.ram", + machine->ram_size); + + ram_below_4g =3D g_malloc(sizeof(*ram_below_4g)); + memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, + 0, x86ms->below_4g_mem_size); + memory_region_add_subregion(system_memory, 0, ram_below_4g); + + e820_add_entry(0, x86ms->below_4g_mem_size, E820_RAM); + + if (x86ms->above_4g_mem_size > 0) { + ram_above_4g =3D g_malloc(sizeof(*ram_above_4g)); + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, + x86ms->below_4g_mem_size, + x86ms->above_4g_mem_size); + memory_region_add_subregion(system_memory, 0x100000000ULL, + ram_above_4g); + e820_add_entry(0x100000000ULL, x86ms->above_4g_mem_size, E820_RAM); + } + + fw_cfg =3D fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, + &address_space_memory); + + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, machine->smp.cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, machine->smp.max_cpus); + fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); + fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override(= )); + fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, + &e820_reserve, sizeof(e820_reserve)); + fw_cfg_add_file(fw_cfg, "etc/e820", e820_table, + sizeof(struct e820_entry) * e820_get_num_entries()); + + rom_set_fw(fw_cfg); + + if (machine->kernel_filename !=3D NULL) { + x86_load_linux(x86ms, fw_cfg, 0, true, true); + } + + if (mms->option_roms) { + for (i =3D 0; i < nb_option_roms; i++) { + rom_add_option(option_rom[i].name, option_rom[i].bootindex); + } + } + + x86ms->fw_cfg =3D fw_cfg; + x86ms->ioapic_as =3D &address_space_memory; +} + +static gchar *microvm_get_mmio_cmdline(gchar *name) +{ + gchar *cmdline; + gchar *separator; + long int index; + int ret; + + separator =3D g_strrstr(name, "."); + if (!separator) { + return NULL; + } + + if (qemu_strtol(separator + 1, NULL, 10, &index) !=3D 0) { + return NULL; + } + + cmdline =3D g_malloc0(VIRTIO_CMDLINE_MAXLEN); + ret =3D g_snprintf(cmdline, VIRTIO_CMDLINE_MAXLEN, + " virtio_mmio.device=3D512@0x%lx:%ld", + VIRTIO_MMIO_BASE + index * 512, + VIRTIO_IRQ_BASE + index); + if (ret < 0 || ret >=3D VIRTIO_CMDLINE_MAXLEN) { + g_free(cmdline); + return NULL; + } + + return cmdline; +} + +static void microvm_fix_kernel_cmdline(MachineState *machine) +{ + X86MachineState *x86ms =3D X86_MACHINE(machine); + BusState *bus; + BusChild *kid; + char *cmdline; + + /* + * Find MMIO transports with attached devices, and add them to the ker= nel + * command line. + * + * Yes, this is a hack, but one that heavily improves the UX without + * introducing any significant issues. + */ + cmdline =3D g_strdup(machine->kernel_cmdline); + bus =3D sysbus_get_default(); + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev =3D kid->child; + ObjectClass *class =3D object_get_class(OBJECT(dev)); + + if (class =3D=3D object_class_by_name(TYPE_VIRTIO_MMIO)) { + VirtIOMMIOProxy *mmio =3D VIRTIO_MMIO(OBJECT(dev)); + VirtioBusState *mmio_virtio_bus =3D &mmio->bus; + BusState *mmio_bus =3D &mmio_virtio_bus->parent_obj; + + if (!QTAILQ_EMPTY(&mmio_bus->children)) { + gchar *mmio_cmdline =3D microvm_get_mmio_cmdline(mmio_bus-= >name); + if (mmio_cmdline) { + char *newcmd =3D g_strjoin(NULL, cmdline, mmio_cmdline= , NULL); + g_free(mmio_cmdline); + g_free(cmdline); + cmdline =3D newcmd; + } + } + } + } + + fw_cfg_modify_i32(x86ms->fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(cmdline) = + 1); + fw_cfg_modify_string(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA, cmdline); +} + +static void microvm_machine_state_init(MachineState *machine) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(machine); + X86MachineState *x86ms =3D X86_MACHINE(machine); + Error *local_err =3D NULL; + + microvm_memory_init(mms); + + x86_cpus_init(x86ms, CPU_VERSION_LATEST); + if (local_err) { + error_report_err(local_err); + exit(1); + } + + microvm_devices_init(mms); +} + +static void microvm_machine_reset(MachineState *machine) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(machine); + CPUState *cs; + X86CPU *cpu; + + if (machine->kernel_filename !=3D NULL && + mms->auto_kernel_cmdline && !mms->kernel_cmdline_fixed) { + microvm_fix_kernel_cmdline(machine); + mms->kernel_cmdline_fixed =3D true; + } + + qemu_devices_reset(); + + CPU_FOREACH(cs) { + cpu =3D X86_CPU(cs); + + if (cpu->apic_state) { + device_reset(cpu->apic_state); + } + } +} + +static void microvm_machine_get_pic(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + OnOffAuto pic =3D mms->pic; + + visit_type_OnOffAuto(v, name, &pic, errp); +} + +static void microvm_machine_set_pic(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &mms->pic, errp); +} + +static void microvm_machine_get_pit(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + OnOffAuto pit =3D mms->pit; + + visit_type_OnOffAuto(v, name, &pit, errp); +} + +static void microvm_machine_set_pit(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &mms->pit, errp); +} + +static void microvm_machine_get_rtc(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + OnOffAuto rtc =3D mms->rtc; + + visit_type_OnOffAuto(v, name, &rtc, errp); +} + +static void microvm_machine_set_rtc(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &mms->rtc, errp); +} + +static bool microvm_machine_get_isa_serial(Object *obj, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + return mms->isa_serial; +} + +static void microvm_machine_set_isa_serial(Object *obj, bool value, + Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + mms->isa_serial =3D value; +} + +static bool microvm_machine_get_option_roms(Object *obj, Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + return mms->option_roms; +} + +static void microvm_machine_set_option_roms(Object *obj, bool value, + Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + mms->option_roms =3D value; +} + +static bool microvm_machine_get_auto_kernel_cmdline(Object *obj, Error **e= rrp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + return mms->auto_kernel_cmdline; +} + +static void microvm_machine_set_auto_kernel_cmdline(Object *obj, bool valu= e, + Error **errp) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + mms->auto_kernel_cmdline =3D value; +} + +static void microvm_machine_initfn(Object *obj) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); + + /* Configuration */ + mms->pic =3D ON_OFF_AUTO_AUTO; + mms->pit =3D ON_OFF_AUTO_AUTO; + mms->rtc =3D ON_OFF_AUTO_AUTO; + mms->isa_serial =3D true; + mms->option_roms =3D true; + mms->auto_kernel_cmdline =3D true; + + /* State */ + mms->kernel_cmdline_fixed =3D false; +} + +static void microvm_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->init =3D microvm_machine_state_init; + + mc->family =3D "microvm_i386"; + mc->desc =3D "microvm (i386)"; + mc->units_per_default_bus =3D 1; + mc->no_floppy =3D 1; + mc->max_cpus =3D 288; + mc->has_hotpluggable_cpus =3D false; + mc->auto_enable_numa_with_memhp =3D false; + mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; + mc->nvdimm_supported =3D false; + + /* Avoid relying too much on kernel components */ + mc->default_kernel_irqchip_split =3D true; + + /* Machine class handlers */ + mc->reset =3D microvm_machine_reset; + + object_class_property_add(oc, MICROVM_MACHINE_PIC, "OnOffAuto", + microvm_machine_get_pic, + microvm_machine_set_pic, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, MICROVM_MACHINE_PIC, + "Enable i8259 PIC", &error_abort); + + object_class_property_add(oc, MICROVM_MACHINE_PIT, "OnOffAuto", + microvm_machine_get_pit, + microvm_machine_set_pit, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, MICROVM_MACHINE_PIT, + "Enable i8254 PIT", &error_abort); + + object_class_property_add(oc, MICROVM_MACHINE_RTC, "OnOffAuto", + microvm_machine_get_rtc, + microvm_machine_set_rtc, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, MICROVM_MACHINE_RTC, + "Enable MC146818 RTC", &error_abort); + + object_class_property_add_bool(oc, MICROVM_MACHINE_ISA_SERIAL, + microvm_machine_get_isa_serial, + microvm_machine_set_isa_serial, + &error_abort); + object_class_property_set_description(oc, MICROVM_MACHINE_ISA_SERIAL, + "Set off to disable the instantiation an ISA serial port", + &error_abort); + + object_class_property_add_bool(oc, MICROVM_MACHINE_OPTION_ROMS, + microvm_machine_get_option_roms, + microvm_machine_set_option_roms, + &error_abort); + object_class_property_set_description(oc, MICROVM_MACHINE_OPTION_ROMS, + "Set off to disable loading option ROMs", &error_abort); + + object_class_property_add_bool(oc, MICROVM_MACHINE_AUTO_KERNEL_CMDLINE, + microvm_machine_get_auto_kernel_cmdline, + microvm_machine_set_auto_kernel_cmdline, + &error_abort); + object_class_property_set_description(oc, + MICROVM_MACHINE_AUTO_KERNEL_CMDLINE, + "Set off to disable adding virtio-mmio devices to the kernel cmdli= ne", + &error_abort); +} + +static const TypeInfo microvm_machine_info =3D { + .name =3D TYPE_MICROVM_MACHINE, + .parent =3D TYPE_X86_MACHINE, + .instance_size =3D sizeof(MicrovmMachineState), + .instance_init =3D microvm_machine_initfn, + .class_size =3D sizeof(MicrovmMachineClass), + .class_init =3D microvm_class_init, + .interfaces =3D (InterfaceInfo[]) { + { } + }, +}; + +static void microvm_machine_init(void) +{ + type_register_static(µvm_machine_info); +} +type_init(microvm_machine_init); diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h new file mode 100644 index 0000000..ba68d1f --- /dev/null +++ b/include/hw/i386/microvm.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#ifndef HW_I386_MICROVM_H +#define HW_I386_MICROVM_H + +#include "qemu-common.h" +#include "exec/hwaddr.h" +#include "qemu/notify.h" + +#include "hw/boards.h" +#include "hw/i386/x86.h" + +/* Platform virtio definitions */ +#define VIRTIO_MMIO_BASE 0xc0000000 +#define VIRTIO_IRQ_BASE 5 +#define VIRTIO_NUM_TRANSPORTS 8 +#define VIRTIO_CMDLINE_MAXLEN 64 + +/* Machine type options */ +#define MICROVM_MACHINE_PIT "pit" +#define MICROVM_MACHINE_PIC "pic" +#define MICROVM_MACHINE_RTC "rtc" +#define MICROVM_MACHINE_ISA_SERIAL "isa-serial" +#define MICROVM_MACHINE_OPTION_ROMS "x-option-roms" +#define MICROVM_MACHINE_AUTO_KERNEL_CMDLINE "auto-kernel-cmdline" + +typedef struct { + X86MachineClass parent; + HotplugHandler *(*orig_hotplug_handler)(MachineState *machine, + DeviceState *dev); +} MicrovmMachineClass; + +typedef struct { + X86MachineState parent; + + /* Machine type options */ + OnOffAuto pic; + OnOffAuto pit; + OnOffAuto rtc; + bool isa_serial; + bool option_roms; + bool auto_kernel_cmdline; + + /* Machine state */ + bool kernel_cmdline_fixed; +} MicrovmMachineState; + +#define TYPE_MICROVM_MACHINE MACHINE_TYPE_NAME("microvm") +#define MICROVM_MACHINE(obj) \ + OBJECT_CHECK(MicrovmMachineState, (obj), TYPE_MICROVM_MACHINE) +#define MICROVM_MACHINE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(MicrovmMachineClass, obj, TYPE_MICROVM_MACHINE) +#define MICROVM_MACHINE_CLASS(class) \ + OBJECT_CLASS_CHECK(MicrovmMachineClass, class, TYPE_MICROVM_MACHINE) + +#endif --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571926239; cv=none; d=zoho.com; s=zohoarc; b=eyQAK5QyBbWWpkLzFRwRgvbi+BUWqTpUxCBWaEqcZAUAFI/c6rQyM07h0OW+0O34IdNiWgCqfXdUygl6xrJ5Y9KrDlgwDdxg/YKIeoJFWRXUTUoxrhjXuZ4Fuq2Syw4UhafwHOgYxUGU3Rx7Tj6B9burom8vAuUz9j1bpf44vX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571926239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KFoaCTpYKZuGSbpa+7c7e1feXYIhKJED+OF4NhJ9Cig=; b=ARqsF6uU1NVGT3Mzs5l8jhYtjNLjh9XNv4Aq5cNX0MLM2yoC94sLmyvLy9mrvqjOLFNC17xc4306oBYVx+PblXolJwcq6kRFyMfR08fVw1F7I4PG9d3Cm+FBaJQzzeqw5HrBntcrvOvJZPq3o2jGslXiEViQczssjPbRbgOTksg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571926239459186.0318196271628; Thu, 24 Oct 2019 07:10:39 -0700 (PDT) Received: from localhost ([::1]:43688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdoz-00017T-NB for importer@patchew.org; Thu, 24 Oct 2019 10:10:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34787) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdix-0007pF-6Z for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiv-0007kE-V9 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:22 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:45362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdiv-0007jo-Oq for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:21 -0400 Received: by mail-wr1-x42f.google.com with SMTP id q13so21265465wrs.12 for ; Thu, 24 Oct 2019 07:04:21 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KFoaCTpYKZuGSbpa+7c7e1feXYIhKJED+OF4NhJ9Cig=; b=sG5rF5CUwDzs3pTMdK8OirpoSb/cxdmi9jdvwtOLr9yhZfAw8NnFpTvfjTEmTtK5Gc fX0Hb7hGp/rqhJYbkMnJpiR7VqB+/tv+dCSHgqo7k2w3MlJRpl6jdtxG1MDjkw5O0OlE 8zIzYmqCN3nuGUUxXOrhO55UK+F8QXggdl/ec1/gv+QAxdUw8UJbx9jlS7hHrkmIaW3/ k/I+uO8gwnf2fehwta4Mg+clueVq/aap1NXJK4WqLbL8ePAJAlD7uXs3Y6iQcz8/4DU0 NXsLlSbd+S+IUL0qezhFKHA2+OqFZDfKNjn7egI2DjlUrBwGQxexAlnRvihfMLqDwsqU q3pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KFoaCTpYKZuGSbpa+7c7e1feXYIhKJED+OF4NhJ9Cig=; b=M1qDDvD3RswtztLY5Hwh0zAgktHoDewPeXLbFn5ynxhNFWAJMYkNRPwszageFIAwtB dQwB6HYgj2UcFO7hp02Fx3mrIdUaBafww/wDGhlXJ8Wdfio1Uwu/EdgrwKxKQkZUMd2y J7inprPHIVhmzF1tMyeUERR5zNuuqNBVtrI8fzeRsPzSgoVd4P0tEHiW8QI7zk3/a69A psDYZJvRU2nWOxpRTtBOyzPusqVdO/nmWnSBui5SbiYMHgqRKqgXqWaJc3w+3+WwHnf1 SSXiNOXFI2bNpVCt715rs9OgzMtvqbC6VuXGIXkqAv4UjAF58rQOhOmyjxx+NTQz6BR5 184g== X-Gm-Message-State: APjAAAWkAuRS0iiMYqcII6DGbOBBv/9W/nBdzArOHZS/ynORfRycoFjh 0WWncq1H5fFIQTc/4DtXMrZuLeir X-Google-Smtp-Source: APXvYqyUtTPAhPOmxY7FJochviyHTFZGfClWs+lmG8qJn1JelX2oBeDppy9GP1O0WzhFHwcoSu1RVg== X-Received: by 2002:a05:6000:11cd:: with SMTP id i13mr3898816wrx.197.1571925860485; Thu, 24 Oct 2019 07:04:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 21/39] MAINTAINERS: add microvm related files Date: Thu, 24 Oct 2019 16:03:37 +0200 Message-Id: <1571925835-31930-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sergio Lopez Add a new "microvm" section under "X86 Machines" with the new files related to this machine type. Signed-off-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 250ce8e..72ab731 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1275,6 +1275,15 @@ F: include/hw/timer/hpet.h F: include/hw/timer/i8254* F: include/hw/timer/mc146818rtc* =20 +microvm +M: Sergio Lopez +M: Paolo Bonzini +S: Maintained +F: docs/microvm.rst +F: hw/i386/microvm.c +F: include/hw/i386/microvm.h +F: pc-bios/bios-microvm.bin + Machine core M: Eduardo Habkost M: Marcel Apfelbaum --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571928792; cv=none; d=zoho.com; s=zohoarc; b=kd06j3G56dVvL5jjeYeStOzHnhS88EG9aVzQoFLsuOR7uZ6mkhKMGqSjuIVHld8rrD0ozhee0q8F89pbYvAdG69Y68zhMaRzEP8PHbznoJDo4lKjn9hdxsDhEU25ZfN2pWz9rcigANO6aAA09WRfq0VheN4hwblr6F/jwvZM2ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571928792; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=VxP5UE5BCXFLhC5XcjHpWnJKP5zOKoEUmAkBP6uQR5E=; b=JiNzGLwJZdo+MWrZOKjKSgldBDJAYJeTHlkanM/Ow7Au/jAUTI5/YovRc4BgaRUWhpAKSgfo8refQXrHFhfA/msORs4hEPQu3xODdT53Nf73Er55yT+6nwJR0ntbc5vST8dHMNN1Dy7Eqbz/AeWFMvCbP4CqMC/dCQi8gUYisaw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571928792446448.43218914409726; Thu, 24 Oct 2019 07:53:12 -0700 (PDT) Received: from localhost ([::1]:44712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeUA-0000JV-H1 for importer@patchew.org; Thu, 24 Oct 2019 10:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34819) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiy-0007rU-Bn for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiw-0007kk-Qz for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:39998) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdiw-0007kL-Ks for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:22 -0400 Received: by mail-wm1-x334.google.com with SMTP id w9so1562808wmm.5 for ; Thu, 24 Oct 2019 07:04:22 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VxP5UE5BCXFLhC5XcjHpWnJKP5zOKoEUmAkBP6uQR5E=; b=FtYaImCerhgmONNB4V1RofJlku4Z6xB5kwbcx65CPuMctA4nq2N4Q68nq841Fa9/7W XcCwwnyB7GxUU5vyCUag6ZFOM9URkSKZR/t1vfR15nGwOBA1IAe/ip/oAvi/OUGJha8w i+wF9dIcQIh+JtNUH9F64XtGWRO+iDyKlXsGpnEXSvySC9FUuG03u0vj/eYxHr5+j9JE ffuP5YW0JYBOQXuk4hrgtJkx0oFvlez7LsBIUru/Ot0LL0wO81RGIZ1R5LkZ3aWAzWTC 7PGFApGc8WQUaedROHcOBXwDM9cM/u+WZiUQFXz5yrVZjAal6QKUecAvma9iL40H55sJ ftCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VxP5UE5BCXFLhC5XcjHpWnJKP5zOKoEUmAkBP6uQR5E=; b=Ic7ykaF7WrqdV/162iPGipIO+h64+dobfhe6TNC5//+lJqX5hyAxaz20Xtr5M+DlKW nkIZpu3RULldkZu72kCtpbK9C+g9ZDHCAjRE0l4GWSOIZEA6NUHUHSsOGuidreAEBL5a EM/cUdIHc7W2roGjRMI/tbZ6sCFCl0LNnxGRqR8ml5AcTzFWwzsfZBgLhqsYgyxxJKp4 N6xEn/Cbvq+FNeayzCbUvDKMd+N5/LSba1ZftekQkB2deUb9dUkmrWSYSEhcB3bNUvMr V4cO3Ww6xESyV5cpekvrBYFCUp3/mBrz1IR08Vv4RK22FcQGDdbFn/3V3M9l/AQ2rdLM CXIA== X-Gm-Message-State: APjAAAUxd6Unyn73flpf3HQ/R78wv2g/EvwrfxXxqA/FkuWBxg/fI2vY XvKp+m0zFYJlCKTd2hL1FG6jtLSj X-Google-Smtp-Source: APXvYqxi0x4/74E8dAI2vTtTxCOwIUaRHZSKgRiVOwyU7WO2QCZkxGPsi0a5UgCJ1eIEf/O7N4VOzA== X-Received: by 2002:a1c:e91a:: with SMTP id q26mr451061wmc.32.1571925861440; Thu, 24 Oct 2019 07:04:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 22/39] checkpatch: suggest qemu_real_host_page_size instead of getpagesize() or sysconf(_SC_PAGESIZE) Date: Thu, 24 Oct 2019 16:03:38 +0200 Message-Id: <1571925835-31930-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Wei Yang , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Yang Signed-off-by: Wei Yang CC: Richard Henderson CC: Stefan Hajnoczi Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Message-Id: <20191017004633.13229-1-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index aa9a354..ab68a16 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2915,6 +2915,12 @@ sub process { if ($line =3D~ /\bbzero\(/) { ERROR("use memset() instead of bzero()\n" . $herecurr); } + if ($line =3D~ /\bgetpagesize\(\)/) { + ERROR("use qemu_real_host_page_size instead of getpagesize()\n" . $here= curr); + } + if ($line =3D~ /\bsysconf\(_SC_PAGESIZE\)/) { + ERROR("use qemu_real_host_page_size instead of sysconf(_SC_PAGESIZE)\n"= . $herecurr); + } my $non_exit_glib_asserts =3D qr{g_assert_cmpstr| g_assert_cmpint| g_assert_cmpuint| --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930151; cv=none; d=zoho.com; s=zohoarc; b=aBvUspPZyQBIAaWe9KyyWxJKAbbpiQivyomfp1d2dWnyEIgkRvCkSRydwBxso2KN5KTCPk1eHflUbpRVnBkBrkG+PCiu5jdXR+nYbBflAaorzTyqoWf6PJ/eZVtyTCl4VfyddjkLAgEzyUbhSdnDTdsEkq1sLVzZaimcomox8HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930151; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LjDK3UIIIZQzr+ukaPn01yLRu1TJq8EAIxhDuDy+SXg=; b=abS2Ioqpvx/VZCAk8nWlnhPFOc4zSiKGTogkrYgyI73zNzGlvROpbGkOGFBz4Q4PthGhBaQm2SkVxAuoXn/2tUWvFCMbviDf9Ox8JmxB4GtfJ/61+e0ZD+OR7u4ugL4ulZKkfNEwzwh/ibJH3p1yr8aNYMtRmX7snxEZZ1ZL9l4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930151472209.07714381266953; Thu, 24 Oct 2019 08:15:51 -0700 (PDT) Received: from localhost ([::1]:45226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeq6-0004Eu-5R for importer@patchew.org; Thu, 24 Oct 2019 11:15:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34839) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdiz-0007ss-8J for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiy-0007lH-3b for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:25 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:36479) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdix-0007ku-TS for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:24 -0400 Received: by mail-wm1-x335.google.com with SMTP id c22so2746815wmd.1 for ; Thu, 24 Oct 2019 07:04:23 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LjDK3UIIIZQzr+ukaPn01yLRu1TJq8EAIxhDuDy+SXg=; b=Fq/iCStVsMtikAhxEuVBI29wx6aUgrAJ76Ha9z6NOX5XwEwa7KBFRBdg80DU+0ZmOo wY9ZEujr0+BNQkOXUyPRvveMgIbLq0wHANG1bid4aqHK/h7nh1GbgagzKihbZQinM0Ul Tuj795UBsYHt3+2CgGmgSD8eFHHaRAMQjpDaXkyP1PJLl6CsS1J8bX2FTHntyT6aD7TQ U2TYbGt0lz9ICx295CNfN59bJZkR4G2En0UO/bwTeIQnVcZNnP9kU8Jwa9z+iNOKQghQ h5BYqyPqXmcAf9NI+zeAm5QlhxWfQ/JpUf7dL7R8N23KKGWTyHmDZl+KbHcON3QWOgFb K9Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=LjDK3UIIIZQzr+ukaPn01yLRu1TJq8EAIxhDuDy+SXg=; b=uUw3inW8vDVu+nYjpm2LklBjkAz87zmyjNVuxVcUN8BjzVMhJlXn6HOA/6Y05KudDh YOSJxxK5J4xD2Nj2VWTxAbb+vAt54+8gauHAZaR98LY0Wjj4F36ZQpf8ql6YZ3jE0yce kDjsRtF/HblR0so+7IBlG7h56icqA36yPunBRConAyN2tM7XRVh+y4bUAqPJ/7KY5BBQ CxMsicnBw0/SvuhwiF/bLkYlUobVLXg48eeATUGZeSio/wUaUfj4QT17fhR7WwsvU/zW cgdGQmDAkHA47suWDaBWthY2uqHuPlstPnJvQxh80dmA7tcj6UtZdGF/txDFYOt2XhZa 3g6A== X-Gm-Message-State: APjAAAX6F1UiX+8LY9O8OVWaZ5YdLWOjqKZ2PZbzUFjU4QWHJRhWoJmN l2GDcLwcg2pmwjJ+kEeuuyB2hBFM X-Google-Smtp-Source: APXvYqyY9vW16QAzONpJk+3GLp6dtHxXrtA5/Q4kUU1312KVwychF1s9x2RQWlWYXTdeHkY+e/FAkw== X-Received: by 2002:a7b:ca54:: with SMTP id m20mr5280064wml.142.1571925862669; Thu, 24 Oct 2019 07:04:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 23/39] runstate: ignore exit request in finish migrate state Date: Thu, 24 Oct 2019 16:03:39 +0200 Message-Id: <1571925835-31930-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Laurent Vivier Trying to reboot a VM while a migration is running can move to the prelaunch state (because of the reset) while the runstate is in finish migrate state. As the logical step after the finish migrate is postmigrate, this can create an invalid state transition from prelaunch state to postmigrate state and this raises an error and aborts: invalid runstate transition: 'prelaunch' -> 'postmigrate' As we are not able to manage reset in finish migrate state the best we can do is to ignore any changes and delay them until the next state which should be postmigrate and which should allow this kind of transition. Reported-by: Luk=C3=A1=C5=A1 Doktor Suggested-by: Dr. David Alan Gilbert Signed-off-by: Laurent Vivier Message-Id: <20191017101806.3644-1-lvivier@redhat.com> Signed-off-by: Paolo Bonzini --- vl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vl.c b/vl.c index 4489cfb..4a7d011 100644 --- a/vl.c +++ b/vl.c @@ -1744,6 +1744,9 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 + if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { + return false; + } if (preconfig_exit_requested) { if (runstate_check(RUN_STATE_PRECONFIG)) { runstate_set(RUN_STATE_PRELAUNCH); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930761; cv=none; d=zoho.com; s=zohoarc; b=DU7hRAKzu9f9j00QwKTcSAPDI7lQgVdiHByBwBVGRy5paGvC+VMzgMGvf9luHlgcl6ATh9subz3kv/mKoWN2mLOEh2/kcF8QKT7ZR65cEsOY2U1jTJvMAC8bFQBw4T97ofLwxKO7/0rEgKt87QKnTRtJIoczK0dTvPRj2dHqbuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930761; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7GTd0Y4rUsiUUYjOXhHXbd2x4/qEqgV6Jh7YlKYq2OY=; b=SuikkrKOGB/vUvfMbCshyvT83ug2AukXB6PcRi2euIicmU0vqGaENbRwMfLvQVBjHRpPRnW6ZT66b72+0CyhjAn2bqeUdZFiVC8/k2NSIx7eRveLPium4BhRx24UwAuX03zZZqDDM7NhBmLnS0wszVr+QooBej0Syd+5aHDNXOw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930761805215.43483419445988; Thu, 24 Oct 2019 08:26:01 -0700 (PDT) Received: from localhost ([::1]:45380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNezw-0000Z3-Og for importer@patchew.org; Thu, 24 Oct 2019 11:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34856) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj0-0007vT-GO for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdiz-0007m2-Ah for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:26 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:45369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdiz-0007lU-4M for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:25 -0400 Received: by mail-wr1-x436.google.com with SMTP id q13so21265717wrs.12 for ; Thu, 24 Oct 2019 07:04:25 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7GTd0Y4rUsiUUYjOXhHXbd2x4/qEqgV6Jh7YlKYq2OY=; b=FadYr7DeaU2z/kPbeGixm/CF3srccqBCeeTzhUD21MqS4lBqM8CNuJORHtxbjZK4S/ qcVACiMHClZ7dKmF0ibDP9DmGk7ZOTCLZDt+nEEy9peVBdNovMHkB7Oe3WHFpOKbMwqC F3HEjFDjAdqPiw8LDVQ0uKbP3XFRDvcEEktQGepExQr9pss0t6F1i78ftjEkQkCCkf/5 NtziyQzSMlRT4zDNayvtQw6FJixw4LQIPgBW0eIxNyAvkNo8FpCaTIXZb5GZKMSkn0Yx byw/RYH4zH9aOfCIuYuoqM8y+5G5E2g2O5zxaoP7SW4oNCctcon9xPSGK7sGJcv2MfhR JX0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7GTd0Y4rUsiUUYjOXhHXbd2x4/qEqgV6Jh7YlKYq2OY=; b=F3/B+PB3xhELVWeRf5GV4j8QqxoyetBVnYTjXV6Y9cqaZfoUXgs7y02+uoa8UhlX69 vnemIzWPCzeGnVlMJc9c5bWczDMJ/wWDZOSRkaF/NAThasJYKaBvefSJSfE5StD8UnAe xYlUOW4jDiKmmhbZLllsNzJOuUDN1G3EW4gHIjMWfvdzFjHQU/Z1tIvjXcR4Q3ah5nrl +DnQbqetQg9KOr75ut57dCM5YbpAnFGbCYwU5mXhNCe+LgY1Yi8TZrS6YozrFgyg/JEA gDhTbzSgNcDQ853HuogJrmx3fMjRad5v9lEaZjjcPDCQ3+omC4ZmGaeeSrYRglofKqo7 UuyQ== X-Gm-Message-State: APjAAAWOtBjPW/o1tXBUBcpasdqPIRisXG3d9Lh/GBh/i7lp/dedjTYP 723jlpYHoQlTzR57qWeq9CDrzGp3 X-Google-Smtp-Source: APXvYqwa/DSSmc9ZUag4HqvzvlUhpgy7cZ3c7HSq4u+f/uNPA4s/KDStNkv3NO8eAgJGBd1t3MLLIg== X-Received: by 2002:adf:9c81:: with SMTP id d1mr3872040wre.238.1571925863761; Thu, 24 Oct 2019 07:04:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 24/39] hw/timer/mc146818rtc: Only include qapi-commands-misc on I386 Date: Thu, 24 Oct 2019 16:03:40 +0200 Message-Id: <1571925835-31930-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Commit a6c7040fb09 restricted the rtc-reset-reinjection command to the I386 target. Restrict the "qapi/qapi-commands-misc-target.h" header to it too. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191017162614.21327-1-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/timer/mc146818rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 0e7cf97..c979db0 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -37,12 +37,12 @@ #include "hw/timer/mc146818rtc.h" #include "migration/vmstate.h" #include "qapi/error.h" -#include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-events-misc-target.h" #include "qapi/visitor.h" #include "exec/address-spaces.h" =20 #ifdef TARGET_I386 +#include "qapi/qapi-commands-misc-target.h" #include "hw/i386/apic.h" #endif =20 --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571930992; cv=none; d=zoho.com; s=zohoarc; b=MclW/0Xc3ZsHBYY+JNET7LuOWrT3ax0bRjcBV42gtClXCS22wgu5ZXw8QNFkWwbXeKYNJy9blY+Q4iPPSIp9MjVDa0vzaxi8RqxNRV3HbIp3FR39bqE+Ilo4Rzm3TMxl64gxgGhbeSvqeDIqnnVXwskRrNzUqtPdzD6AR1eCm1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571930992; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kzf1c4TzoS2R1SZRxcUgo2l6hUVF5Eo0UE969kM5Oa0=; b=cPX/i4RYkK9Bdyp5PF6dNCluYuorFI+xgC/elSEZ3urDxYBGSm41V4IQ1cE313yzrUnP+kOGUDEyIahQemne1br6x+6rSTq814IPlEVYJ+JHW9ehBsV+BEy1vasE1IF5zuQeKQnECIHA5Xl3eMO5v3gsfZ90IwBTY6U5+UK/3n4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571930992271319.3316247477277; Thu, 24 Oct 2019 08:29:52 -0700 (PDT) Received: from localhost ([::1]:45410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf3d-00041j-2B for importer@patchew.org; Thu, 24 Oct 2019 11:29:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34912) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj5-00085c-T7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj0-0007mh-MA for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:31 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj0-0007mK-FT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:26 -0400 Received: by mail-wr1-x441.google.com with SMTP id w18so25704097wrt.3 for ; Thu, 24 Oct 2019 07:04:26 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kzf1c4TzoS2R1SZRxcUgo2l6hUVF5Eo0UE969kM5Oa0=; b=Cdi8J5G9WR+ndYXf7tLlWejwFtV5vnf/Rr/CMx1lmiu1wk0LbSjBopudbufhFNvSZu CwMS/UTaAEoyJEAYewA6PdWbAejEEKBGPCKdzpcW1IjvF0pAwQi70HNwIKFdoBWmC7XN CxGuxJhP5+ni9LnBIG2ZctCYD8z90h7EH4VhPKLjYfwtImTqI+79Oiif0v4xbHbr1Pkz jAEM0HRMj/yI5MOQkkhht5BPkxzF/Yc7HM/sU4aaldng150RuM4Ix3JAWlOhklVYXhC8 86VwYVf1J4QdwLHt+gLNGQ/hLmEGfcc4UEW14vqQhBIHNcj9IaMlW/U6wdCNHxfKHr4v 40hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Kzf1c4TzoS2R1SZRxcUgo2l6hUVF5Eo0UE969kM5Oa0=; b=r5sbHEX7k7Jh3EPbwZIHFuYjp0yfDj+jgEBTzXA5c/2LdtNNcrIwpk+Qj+mAze0zoI TkK5Xfnd2JGiHB7RcWQlnpmbv8nbPggv/gF4Aa0pSeWDzX+AqSHUM2uZJZGudz0l2vLO +j/IhtPF9rE1Gf9pK8ckhC3D8bqxl3XoSq/Dds3VHsCvL6sE04I6CajM+wQOgq4Jtw/o 47nN24IT0ZLboURHVvSbkCB+g/ZD9Wk36UJZZFeZv3lizHBz6PrX3GyddQcLvrY0aTjf U8SBW5YM2aEyowFkIdhlm1Xi1Zg1FNchRLHLj2W0DxJMZtZyKZOcBibAc8wqnZ6C8EFy Ltdg== X-Gm-Message-State: APjAAAWY5xYJHTsCa1yBsW0vB8YRfd+TjSmf1Ok5bEGmSB8R/3rjmcAM pQGYKiFs/yQDJeVgprTPsR6PsP6J X-Google-Smtp-Source: APXvYqwOPEWyxZCon/NCiEhGbJNTw9d6Hkezv6qcgkyZQTBlHdXrIvGsbi3b1XwO1HQ1rC6GjcNAeA== X-Received: by 2002:a5d:674f:: with SMTP id l15mr4390717wrw.80.1571925864951; Thu, 24 Oct 2019 07:04:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 25/39] x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE Date: Thu, 24 Oct 2019 16:03:41 +0200 Message-Id: <1571925835-31930-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jingqi Liu , Tao Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Tao Xu UMONITOR, UMWAIT and TPAUSE are a set of user wait instructions. This patch adds support for user wait instructions in KVM. Availability of the user wait instructions is indicated by the presence of the CPUID feature flag WAITPKG CPUID.0x07.0x0:ECX[5]. User wait instructions may be executed at any privilege level, and use IA32_UMWAIT_CONTROL MSR to set the maximum time. The patch enable the umonitor, umwait and tpause features in KVM. Because umwait and tpause can put a (psysical) CPU into a power saving state, by default we dont't expose it to kvm and enable it only when guest CPUID has it. And use QEMU command-line "-overcommit cpu-pm=3Don" (enable_cpu_pm is enabled), a VM can use UMONITOR, UMWAIT and TPAUSE instructions. If the instruction causes a delay, the amount of time delayed is called here the physical delay. The physical delay is first computed by determining the virtual delay (the time to delay relative to the VM=C3=A2=E2=82=AC=E2=84=A2s timestamp counter). Otherwise, UMONITOR, UM= WAIT and TPAUSE cause an invalid-opcode exception(#UD). The release document ref below link: https://software.intel.com/sites/default/files/\ managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf Co-developed-by: Jingqi Liu Signed-off-by: Jingqi Liu Signed-off-by: Tao Xu Message-Id: <20191011074103.30393-2-tao3.xu@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6c87c99..b635302 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1058,7 +1058,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORD= S] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { NULL, "avx512vbmi", "umip", "pku", - NULL /* ospke */, NULL, "avx512vbmi2", NULL, + NULL /* ospke */, "waitpkg", "avx512vbmi2", NULL, "gfni", "vaes", "vpclmulqdq", "avx512vnni", "avx512bitalg", NULL, "avx512-vpopcntdq", NULL, "la57", NULL, NULL, NULL, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c50a9c7..112f867 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -731,6 +731,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_7_0_ECX_PKU (1U << 3) /* OS Enable Protection Keys */ #define CPUID_7_0_ECX_OSPKE (1U << 4) +/* UMONITOR/UMWAIT/TPAUSE Instructions */ +#define CPUID_7_0_ECX_WAITPKG (1U << 5) /* Additional AVX-512 Vector Byte Manipulation Instruction */ #define CPUID_7_0_ECX_AVX512_VBMI2 (1U << 6) /* Galois Field New Instructions */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 49a3011..94c2339 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -401,6 +401,12 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uin= t32_t function, if (host_tsx_blacklisted()) { ret &=3D ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE); } + } else if (function =3D=3D 7 && index =3D=3D 0 && reg =3D=3D R_ECX) { + if (enable_cpu_pm) { + ret |=3D CPUID_7_0_ECX_WAITPKG; + } else { + ret &=3D ~CPUID_7_0_ECX_WAITPKG; + } } else if (function =3D=3D 7 && index =3D=3D 0 && reg =3D=3D R_EDX) { /* * Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM h= osts. --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931523; cv=none; d=zoho.com; s=zohoarc; b=NElBTMiBNoX7TBT7BI2oUS5VkTTXJqTBNkfUaA3EjaAoJ4aR6cwIfdyLOODpmZqCrdzMshbkqGkRGNL2DeIwjIITn5HoF/ATJvsSdWXlZme0WfUMTb6l/XxkudAks1k9/XqHMOqjGmmF28nHs5gyHBqS8dTGY22ijcl6s1xmQgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931523; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fkvm9nrySjtGqEqh6sk4DK7nSHHS/gX3BsRBOkEFvus=; b=UPnAVwOScuAhDcnHs22AiRtzMRR0wwIG5USWMO36bckLhj/kFkrE+MhYlEJgLWgL8Ui8pmSMMzArn+pIgOsARKpBRy0sL3yPYIUsAY0Dgerus1hm/4SeujGMbSvT9KfeE8gzJK2uOty1/Gk3dZMp7QYb7YhDbcsp7C5UYLAJMKk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931523135870.9794095414856; Thu, 24 Oct 2019 08:38:43 -0700 (PDT) Received: from localhost ([::1]:45504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfCD-0002Ne-RD for importer@patchew.org; Thu, 24 Oct 2019 11:38:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34929) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj7-000882-51 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj1-0007nD-SO for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:32 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj1-0007mo-Kl for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:27 -0400 Received: by mail-wm1-x341.google.com with SMTP id n7so2167426wmc.3 for ; Thu, 24 Oct 2019 07:04:27 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fkvm9nrySjtGqEqh6sk4DK7nSHHS/gX3BsRBOkEFvus=; b=keDUGG/yBFtGV3tw0WN+roAJAig/BbaIL5TL8UsKIMmHKdZrNGNomWs8vvDGXJZJQc 4hvk5IqjzwP3RQqJ+tRKAEvq7QXbgihs0K9luApE6DuOCquBPozsHknbVvj12wwfBqdU Ula6s90gUqrZEN5BD6bGJDYPli23wLEGWVHsJJYcdZIwlD3+0HfDsPkz8085BcgWGM7f yyUkjlPZci87gV+dbIWRHqqiHsvNAOmptXzQUR1WXlkURYFKpZ/d9BGnUy68f7yWUA85 X+T79EyMyNNnO9LHWiFWjs2j6ufdxyJ9kAWMxj9hzkm/psva+ZskX9bsJpod5xaLAOXz HYqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=fkvm9nrySjtGqEqh6sk4DK7nSHHS/gX3BsRBOkEFvus=; b=FoMt3pnre1gCkR8IK4zQs4WLU8Vu4WBTsJt1sz8S5eRL/xPdEp3QefXQiV8/8A0egh k2WCZfvWLfOPhDRSqxX7FHg2mfaJvWXeWtVZQG40NLRW0NC6U49oUvRLho3H37fsMhY4 wQxPYAiK4S/78Kn6cupMdwbLjxxM8OqGABRqk0auyyKsRarH6uyrJoiTtz9U2UA67WrZ xiUXlcpWwVjwk7n+ZzeZw2ha0ruPI6aFL8MEGbVRQ2cu91IKcd9BfF42Vd7UzPR2Zpa5 c6MZMTXafOfqsTcBt3EwUetHE+Zi+DfppirugxNJHSLlUu4eeURkAhOxcAEiqv7W16p1 RBuA== X-Gm-Message-State: APjAAAWYLH+wEfAD31pg/YZgfW2qXDRLPKAaqIFr2DVPOmFNw+mFG9e7 BpZmeiaOfhnmqLhGUwywtPudC9Wz X-Google-Smtp-Source: APXvYqyFt9a5EGOmmNolhHIF2RhmlnTgzXeu+AsTZkhVqNvnIkmUcx6GqhI1YugNJWoagccy6cxg5g== X-Received: by 2002:a1c:2d49:: with SMTP id t70mr432720wmt.131.1571925866214; Thu, 24 Oct 2019 07:04:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 26/39] target/i386: Add support for save/load IA32_UMWAIT_CONTROL MSR Date: Thu, 24 Oct 2019 16:03:42 +0200 Message-Id: <1571925835-31930-27-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jingqi Liu , Tao Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tao Xu UMWAIT and TPAUSE instructions use 32bits IA32_UMWAIT_CONTROL at MSR index E1H to determines the maximum time in TSC-quanta that the processor can reside in either C0.1 or C0.2. This patch is to Add support for save/load IA32_UMWAIT_CONTROL MSR in guest. Co-developed-by: Jingqi Liu Signed-off-by: Jingqi Liu Signed-off-by: Tao Xu Message-Id: <20191011074103.30393-3-tao3.xu@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 13 +++++++++++++ target/i386/machine.c | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 112f867..b772e82 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -452,6 +452,7 @@ typedef enum X86Seg { =20 #define MSR_IA32_BNDCFGS 0x00000d90 #define MSR_IA32_XSS 0x00000da0 +#define MSR_IA32_UMWAIT_CONTROL 0xe1 =20 #define MSR_IA32_VMX_BASIC 0x00000480 #define MSR_IA32_VMX_PINBASED_CTLS 0x00000481 @@ -1587,6 +1588,7 @@ typedef struct CPUX86State { uint16_t fpregs_format_vmstate; =20 uint64_t xss; + uint32_t umwait; =20 TPRAccess tpr_access_type; =20 diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 94c2339..bfd09bd 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -95,6 +95,7 @@ static bool has_msr_hv_stimer; static bool has_msr_hv_frequencies; static bool has_msr_hv_reenlightenment; static bool has_msr_xss; +static bool has_msr_umwait; static bool has_msr_spec_ctrl; static bool has_msr_virt_ssbd; static bool has_msr_smi_count; @@ -2005,6 +2006,9 @@ static int kvm_get_supported_msrs(KVMState *s) case MSR_IA32_XSS: has_msr_xss =3D true; break; + case MSR_IA32_UMWAIT_CONTROL: + has_msr_umwait =3D true; + break; case HV_X64_MSR_CRASH_CTL: has_msr_hv_crash =3D true; break; @@ -2684,6 +2688,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, env->xss); } + if (has_msr_umwait) { + kvm_msr_entry_add(cpu, MSR_IA32_UMWAIT_CONTROL, env->umwait); + } if (has_msr_spec_ctrl) { kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, env->spec_ctrl); } @@ -3097,6 +3104,9 @@ static int kvm_get_msrs(X86CPU *cpu) if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0); } + if (has_msr_umwait) { + kvm_msr_entry_add(cpu, MSR_IA32_UMWAIT_CONTROL, 0); + } if (has_msr_spec_ctrl) { kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, 0); } @@ -3349,6 +3359,9 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_IA32_XSS: env->xss =3D msrs[i].data; break; + case MSR_IA32_UMWAIT_CONTROL: + env->umwait =3D msrs[i].data; + break; default: if (msrs[i].index >=3D MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { diff --git a/target/i386/machine.c b/target/i386/machine.c index 2767b30..6481f84 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -943,6 +943,25 @@ static const VMStateDescription vmstate_xss =3D { } }; =20 +static bool umwait_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + + return env->umwait !=3D 0; +} + +static const VMStateDescription vmstate_umwait =3D { + .name =3D "cpu/umwait", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D umwait_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(env.umwait, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + #ifdef TARGET_X86_64 static bool pkru_needed(void *opaque) { @@ -1391,6 +1410,7 @@ VMStateDescription vmstate_x86_cpu =3D { &vmstate_msr_hyperv_reenlightenment, &vmstate_avx512, &vmstate_xss, + &vmstate_umwait, &vmstate_tsc_khz, &vmstate_msr_smi_count, #ifdef TARGET_X86_64 --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931609; cv=none; d=zoho.com; s=zohoarc; b=Op1xfk/7Oa/Uxjuxuy14/BROUrYyrOZD17KIgca0WtKXAF2gXab4EhtW9z+YGEeYCD3tFMJLP3pSNifVJSwXYIo+NPdxIyzJBUN+0sVFtSPAo2wwlgMYXeQ5E+8rrN6yh3z/hz2D6argJGjF8KI5qwYvCAGzNpLAqA9fjHfyIiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931609; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZKfl1Pqq3FGyY1lzuLtSAUoFrIIAbeG7CA7XuDqVexQ=; b=ByNuQgPjbERdRq/hVYljGvePiRzqvsU6HCex2SggFOb8v29fQFEHHEfuh6/xjiry/GfAssDucxeR6ypk7pMa3KFttN8ONa1COpI/cVvMJisRHVcX5D6OK0NK81vszKlRTSls0RUQxxlZ/hiMoVZhd7fGAhYis6UsVbG+zy8pL04= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931609136179.2259115772897; Thu, 24 Oct 2019 08:40:09 -0700 (PDT) Received: from localhost ([::1]:45514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfDb-0005t3-1Y for importer@patchew.org; Thu, 24 Oct 2019 11:40:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34937) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj7-00089b-V9 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj2-0007nd-Tb for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:33 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:36883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj2-0007nL-Lx for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:28 -0400 Received: by mail-wr1-x429.google.com with SMTP id e11so17538338wrv.4 for ; Thu, 24 Oct 2019 07:04:28 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZKfl1Pqq3FGyY1lzuLtSAUoFrIIAbeG7CA7XuDqVexQ=; b=YN6pXa+sf8rVTyeQfBml0lF2fXextF1eTmUy0cNjribSUpFhTIG4Y19e36NPOiVM03 7xyKaeEoPX70BnWfFXsIJvw5A1h00lNtRPeggoI31KLBjsrq49fJoPOyUL4G6Ra9v0ly kH/FZ4SIRjIdGWpYZHvm85ptK5W/5peW2VO4OLqcAfsTNl0hmPvTRq5h28d3AmnSLxRC SwjfVrKv65uuJ3HudfmQto1CndOdu1rU8ygIw2cQJ33kdEC1tkcPaMEYy+9B+z+fMJ6W zkLOKRaRzwJig0E89AG9QYMYaCG0h/ClF7eKTSYVeKd0CBKodGcLkhcabllBu2o96+6A Y4yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZKfl1Pqq3FGyY1lzuLtSAUoFrIIAbeG7CA7XuDqVexQ=; b=ObTxHK91U2J75k9r2RKeXG+x+nUuUlrj6k3QOeMI5V+M3YasnY7+l9fAL4BZjslMOT JkvTQBOPNoglJ/WUxfEUfuWUYod1ThxN19nvmLIlQDV5Vod0wYTc8OUeETiFLtsXquES bdW6Nq+WPgNpxLs9Nr7+1pNoVYV22cSZgkNmv6ccjv2hawgTa8fmFRDRzRQXnh2SSCg7 OVNBS08eRRe9G0TO2L0B2popfdVvCmRKBCrOuipXIhJLctrZVvkyK7vvmAXQ6+wGX7m5 rd/iB/2yi2oKJiLkfHl41mXtCBALobsKfUJSj2oScLNVQt7S76UKC8s6JLVPtlzyro76 KhPw== X-Gm-Message-State: APjAAAX70NzPMp1fuu6uvuFKpLMJ5IFpplQ+w8B58+/nx/PZqoWdw8yI tFfQTBKl7EgLI+6BwUG64iUXaOCz X-Google-Smtp-Source: APXvYqyE0tP6WgmXztxrLj9AtSkpg4kG2uI41EIgkzx82zID+YYP9gAqG2oAHhMqGFjHUW1OZXgKsA== X-Received: by 2002:a5d:638c:: with SMTP id p12mr3755598wru.136.1571925867265; Thu, 24 Oct 2019 07:04:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 27/39] hw/i386/pc: Extract pc_gsi_create() Date: Thu, 24 Oct 2019 16:03:43 +0200 Message-Id: <1571925835-31930-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The GSI creation code is common to all PC machines, extract the common code. Reviewed-by: Aleksandar Markovic Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018135910.24286-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 15 +++++++++++++++ hw/i386/pc_piix.c | 9 +-------- hw/i386/pc_q35.c | 9 +-------- include/hw/i386/pc.h | 2 ++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a8888dd..e8a54ac 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -355,6 +355,21 @@ void gsi_handler(void *opaque, int n, int level) qemu_set_irq(s->ioapic_irq[n], level); } =20 +GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) +{ + GSIState *s; + + s =3D g_new0(GSIState, 1); + if (kvm_ioapic_in_kernel()) { + kvm_pc_setup_irq_routing(pci_enabled); + *irqs =3D qemu_allocate_irqs(kvm_pc_gsi_handler, s, GSI_NUM_PINS); + } else { + *irqs =3D qemu_allocate_irqs(gsi_handler, s, GSI_NUM_PINS); + } + + return s; +} + static void ioport80_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a86317c..0cc951a 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -189,14 +189,7 @@ static void pc_init1(MachineState *machine, xen_load_linux(pcms); } =20 - gsi_state =3D g_malloc0(sizeof(*gsi_state)); - if (kvm_ioapic_in_kernel()) { - kvm_pc_setup_irq_routing(pcmc->pci_enabled); - x86ms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, - GSI_NUM_PINS); - } else { - x86ms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_= PINS); - } + gsi_state =3D pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); =20 if (pcmc->pci_enabled) { pci_bus =3D i440fx_init(host_type, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 75c8caf..255c803 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -212,14 +212,7 @@ static void pc_q35_init(MachineState *machine) } =20 /* irq lines */ - gsi_state =3D g_malloc0(sizeof(*gsi_state)); - if (kvm_ioapic_in_kernel()) { - kvm_pc_setup_irq_routing(pcmc->pci_enabled); - x86ms->gsi =3D qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, - GSI_NUM_PINS); - } else { - x86ms->gsi =3D qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_= PINS); - } + gsi_state =3D pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); =20 /* create pci host bus */ q35_host =3D Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE)); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 13c4eac..8c5dc39 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -157,6 +157,8 @@ typedef struct GSIState { =20 void gsi_handler(void *opaque, int n, int level); =20 +GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled); + /* vmport.c */ #define TYPE_VMPORT "vmport" typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929147; cv=none; d=zoho.com; s=zohoarc; b=B1+e/2NwUTyBzN5zEVIDysYDRXQR7XdHQpISNsnwNLVerc1tQiKD10dOwyfqd2iZbFgWZrQgkwWSWX6X+KpBBpHJ35TV0Hp4/U/dBcblSVF/uBm7IDJel2iZbzehtw5Fv/mtEZlIiVLk4h/TtFloDXq+ZzKCTL9S2opkchzVBaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929147; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=addr6HEN99Dsw110Mj0HtzWMNzU3f7sx/0UbPvS5mDg=; b=Exv+maeMOwlAAX2jdjwGPoUThuRJScpQ1f1V+ktbeqZlLkJPn36Mx//HODtGieN9XaowE7BJfMNOvpAokQy4TNHf2aR15v/pEccKxxAl+guQGeDhaxGJcynQCJ1tFKf8hB+tZVijy+gi5GDEqIYAs3kTI8rm8JkTDT2YENmU7Xk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157192914737779.62669101710742; Thu, 24 Oct 2019 07:59:07 -0700 (PDT) Received: from localhost ([::1]:44840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeZt-0004EJ-Uu for importer@patchew.org; Thu, 24 Oct 2019 10:59:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34903) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj5-00083u-00 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj3-0007o6-Um for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:30 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:54770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj3-0007nl-OU for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:29 -0400 Received: by mail-wm1-x335.google.com with SMTP id g7so2988057wmk.4 for ; Thu, 24 Oct 2019 07:04:29 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=addr6HEN99Dsw110Mj0HtzWMNzU3f7sx/0UbPvS5mDg=; b=OVYHa+s72RwVBjxxCnMtsPt2upmay1bGC+AFoJR2IZhCyo3+ReEjyZklbIg46fnWhK PWVNf4wWgVNNBOJ9GO49ONYujexVF6FbHibvirIQqxd/Tde7W50NZca4dJ60NSBNMRGS zglJRHljvqFJIcJe1zZnjgrchtDy6kL8DSTW7RSeIRsCrzMHFiUFgn3rnEeB8W39qOk/ 8EhMZrnTX6L0IeLNrlPLm7HgTaJkIjgG8CAA5Ew+Ew6M7xySIYeaDm97feblIkLFcfWL JLdTOp/lhLiK8Nag5XmvXJdxQebNQfkqixEEhgds1hn+L0UH3r7I96WFgXu9/9GTvhr7 9Glw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=addr6HEN99Dsw110Mj0HtzWMNzU3f7sx/0UbPvS5mDg=; b=j08V+QW9fI+1eCBgx0i/wTF5wfHkgiMMF5pOsNNvJAwFcNVU2u0CRXiCFVzASwAlkI apCCyjALzl7fHwv2GUQ5X+8EWh580W/iXqhPw3qiEaPpWK/0zx0DACiKYskAy4gbPCJw 56SexboA9VnXn+Ly9S6CKoqy9Ozn3SYJAaJKdI94FZJbRvBPR2xobuxdTeXc944zbOsV UUy/oZfcgteItXTyAyTiLpjgQv4zPWRr4FAO6I/TeJuNkYQz6NQe9WImq5/5JQULCRO0 n/v+HQ7Ytqsp3r76PxyrJBP1MgVGpci3hC2uk4evxU/DcAInUGZ9zk0XCYVzNvKzZuUg j9Qw== X-Gm-Message-State: APjAAAU+4w4cYP1RrWjP/SZWoqyphaCRhb5Cdac0gAoIU2Fj3ETgs8kK uuzNcHZSMYiywa/389Or6aRFtxn2 X-Google-Smtp-Source: APXvYqxLJ9lOZ6z8Vn2vzHR9som7LoayIqV+8eW0LmGrPqRhPiyohTMerHnAyg28NmZZ202G2aQViw== X-Received: by 2002:a1c:7913:: with SMTP id l19mr5394022wme.26.1571925868453; Thu, 24 Oct 2019 07:04:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 28/39] hw/i386/pc: Move gsi_state creation code Date: Thu, 24 Oct 2019 16:03:44 +0200 Message-Id: <1571925835-31930-29-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The code block related to IRQ starts few lines later. Move the comment and the pc_gsi_create() invocation where we start to use the IRQs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018135910.24286-4-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_q35.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 255c803..6cf12b7 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -211,9 +211,6 @@ static void pc_q35_init(MachineState *machine) rom_memory, &ram_memory); } =20 - /* irq lines */ - gsi_state =3D pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); - /* create pci host bus */ q35_host =3D Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE)); =20 @@ -247,6 +244,9 @@ static void pc_q35_init(MachineState *machine) object_property_set_link(OBJECT(machine), OBJECT(lpc), PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); =20 + /* irq lines */ + gsi_state =3D pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); + ich9_lpc =3D ICH9_LPC_DEVICE(lpc); lpc_dev =3D DEVICE(lpc); for (i =3D 0; i < GSI_NUM_PINS; i++) { --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931438; cv=none; d=zoho.com; s=zohoarc; b=P/Hy0rM6v1e1zQDvV5MySS77U2gaCnlfoZQVt+EmgIkhZuEfeNeVF+eAC3Z2jsCEBJ2aVsXVu28p6wACWxJP2NWReUNRIEUFzv8b+RVfxjeUnqOtUyoqxa6bIyJlrn3O9Auy5fc6zpEO+fds7HFd344wTapXFgabGngic+jCBQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931438; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=icQSYq8suoWhdg2fa8gVI133nwoWV8pjrk93eMBlBGA=; b=UeiCelKLDiDldO4Zbby1ZjDhwfkl4Q51uG99dRkVyOtEwK6Ozx8lYoU6LzQq+fmUyQWcrZ6lcONCa68cxr8evRW7eIslremATdRKU0Qubh1KKtIM43EY8JDEG3GAWX7iKc+NIesC+5z0Xd0cSPUshQ84XWAHYEImLsH9Yox9scU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931438722746.4974861628772; Thu, 24 Oct 2019 08:37:18 -0700 (PDT) Received: from localhost ([::1]:45490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfAr-0005mG-69 for importer@patchew.org; Thu, 24 Oct 2019 11:37:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34965) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjA-0008E7-O7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj5-0007oh-6k for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:36 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:46839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj4-0007oD-W5 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:31 -0400 Received: by mail-wr1-x42c.google.com with SMTP id n15so15445328wrw.13 for ; Thu, 24 Oct 2019 07:04:30 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=icQSYq8suoWhdg2fa8gVI133nwoWV8pjrk93eMBlBGA=; b=MK68BejZ3Z4nC9UHBcYRZ5UWNJLCX4Waik0vNKfwOyZxiQZPRYj7VUkyC4O1Xm38Fu F3OEdrkZrSFU/W5yQZ0QASkYXDchj2moAWCExsUOYmhvXBlHwR7FqO2N7XUU8kk4Cl9T M4lFN7Ew7cRermDhITObQRqXrANBIe8RV5034bmlm2rD2zomYmD7kMYTxF1qRxaBWRE4 P09R5K79otV5hNVqlveA3tgTMsnh7qpwenLg3rclyjBsli74Rgd7D/ZctyKcADmxzyt9 iY1oOu842ETnWp3lsMu1yj3fX7dfBrvL+4nfjPFNJo+ZrIVcusVQQlAAbSDbHbPgH/O2 b1xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=icQSYq8suoWhdg2fa8gVI133nwoWV8pjrk93eMBlBGA=; b=h5eYMQMWNjXbpAXJdgCSi4qrv5gxobbTSxkzLkTJO4ygkaQQK78UxqG07j1S2ZIiPO mpMdaOhXKWZMNP3TOv3ZOJStt4SaJvfknkShlr78mHkHonVpyKTdC5umbVgC7MG5w+Si Pdwp2EZP0kK7qNWAJuPU848iY4lBPVMZ1jEMXaQwOf5zRslmpguxnOaCGoDB7Zdf20RA FM7EwJwthO6Etong1n0pbKIOGQTykZiuCHiEyaEVBEnSec+CaXd2vs0XKDzlKuc8tEVX duRRRJ2+SOTRRIk965+m4Oq5/CxS4gMztnG4DrKSik2Or/ues/onYNXy7dmT7BHzM3kW JE/g== X-Gm-Message-State: APjAAAV6YTz1FobCcjbSDE8cd9bCr2xd2rl2n04oytPW2AU6nL2a99Y4 IB0TT00DtosmcR+3k728Mw6j9MyZ X-Google-Smtp-Source: APXvYqz0P1zbGWLOsz0D0UkdH9BEmAQ9ZTHJSDdmJjDvQ0hSVxEa/dBbWCVK+NJbpElfZHqIVibzpw== X-Received: by 2002:adf:afef:: with SMTP id y47mr2132655wrd.190.1571925869593; Thu, 24 Oct 2019 07:04:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 29/39] hw/i386/pc: Extract pc_i8259_create() Date: Thu, 24 Oct 2019 16:03:45 +0200 Message-Id: <1571925835-31930-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The i8259 creation code is common to all PC machines, extract the common code. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018135910.24286-5-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 19 +++++++++++++++++++ hw/i386/pc_piix.c | 13 +------------ hw/i386/pc_q35.c | 14 +------------- include/hw/i386/pc.h | 1 + 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e8a54ac..5fce60c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1474,6 +1474,25 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_b= us, PCIBus *pci_bus) rom_reset_order_override(); } =20 +void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs) +{ + qemu_irq *i8259; + + if (kvm_pic_in_kernel()) { + i8259 =3D kvm_i8259_init(isa_bus); + } else if (xen_enabled()) { + i8259 =3D xen_interrupt_controller_init(); + } else { + i8259 =3D i8259_init(isa_bus, pc_allocate_cpu_irq()); + } + + for (size_t i =3D 0; i < ISA_NUM_IRQS; i++) { + i8259_irqs[i] =3D i8259[i]; + } + + g_free(i8259); +} + void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name) { DeviceState *dev; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0cc951a..648dc9a 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -82,7 +82,6 @@ static void pc_init1(MachineState *machine, ISABus *isa_bus; PCII440FXState *i440fx_state; int piix3_devfn =3D -1; - qemu_irq *i8259; qemu_irq smi_irq; GSIState *gsi_state; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; @@ -209,18 +208,8 @@ static void pc_init1(MachineState *machine, } isa_bus_irqs(isa_bus, x86ms->gsi); =20 - if (kvm_pic_in_kernel()) { - i8259 =3D kvm_i8259_init(isa_bus); - } else if (xen_enabled()) { - i8259 =3D xen_interrupt_controller_init(); - } else { - i8259 =3D i8259_init(isa_bus, pc_allocate_cpu_irq()); - } + pc_i8259_create(isa_bus, gsi_state->i8259_irq); =20 - for (i =3D 0; i < ISA_NUM_IRQS; i++) { - gsi_state->i8259_irq[i] =3D i8259[i]; - } - g_free(i8259); if (pcmc->pci_enabled) { ioapic_init_gsi(gsi_state, "i440fx"); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 6cf12b7..157d1da 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -130,7 +130,6 @@ static void pc_q35_init(MachineState *machine) MemoryRegion *ram_memory; GSIState *gsi_state; ISABus *isa_bus; - qemu_irq *i8259; int i; ICH9LPCState *ich9_lpc; PCIDevice *ahci; @@ -257,18 +256,7 @@ static void pc_q35_init(MachineState *machine) pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq); isa_bus =3D ich9_lpc->isa_bus; =20 - if (kvm_pic_in_kernel()) { - i8259 =3D kvm_i8259_init(isa_bus); - } else if (xen_enabled()) { - i8259 =3D xen_interrupt_controller_init(); - } else { - i8259 =3D i8259_init(isa_bus, pc_allocate_cpu_irq()); - } - - for (i =3D 0; i < ISA_NUM_IRQS; i++) { - gsi_state->i8259_irq[i] =3D i8259[i]; - } - g_free(i8259); + pc_i8259_create(isa_bus, gsi_state->i8259_irq); =20 if (pcmc->pci_enabled) { ioapic_init_gsi(gsi_state, "q35"); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 8c5dc39..5923318 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -219,6 +219,7 @@ void pc_pci_device_init(PCIBus *pci_bus); =20 typedef void (*cpu_set_smm_t)(int smm, void *arg); =20 +void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs); void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); =20 ISADevice *pc_find_fdc0(void); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571926419; cv=none; d=zoho.com; s=zohoarc; b=B425Ykj2tsTD43rdivLpF4SxqB9hSTDE4nNOfMFXM2/+grH3lq+o2TGB27ndKqgselu4j0NsPDxztcsz8LA0gOLN1vHnUlOrhbgWHDZeS54J3O/6RmGV6rZfCwEu0kF+34cUfgABSIqW4K3VorVE+nzdgdZYo8wugS9QT3TgXdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571926419; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ikbis2EmZPHbVV90StLUr/aGwCPiufobBGQ1XGXra5o=; b=IvYeZq8IyXPnGjz3mKSRvWCyhOvcWCzdnEu5AppqSR1tGWaosgLOgqXIhddFI3czghtXmLlZna6YH+be3dK+HWBlqL7Agh5sp9KspdjVJRUFNfOaCDRBzfzbmRWwYo8rhWLHrD1AtQUI0YddINi/9nXS7z4LPQbgmdwpjftlbE0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571926419304199.2431321697278; Thu, 24 Oct 2019 07:13:39 -0700 (PDT) Received: from localhost ([::1]:43758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdrt-0000GF-Rp for importer@patchew.org; Thu, 24 Oct 2019 10:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34931) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdj7-00088U-EB for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj6-0007pH-8F for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:33 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:39157) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj6-0007ou-28 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:32 -0400 Received: by mail-wm1-x333.google.com with SMTP id r141so2732743wme.4 for ; Thu, 24 Oct 2019 07:04:32 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ikbis2EmZPHbVV90StLUr/aGwCPiufobBGQ1XGXra5o=; b=ZOKx1UsjF2cFt8CIG5BAL16XIvQuYeg4o8U9slre8HF0mLBLNnpMkj5OWudygv+Q6H UyZUQGimyF16DZNrqpe+f7bwU4Ze8vWrtLCkhUkhEFTdSDw7B7emLSAGFB+HjTjhBbMn 2eL+mqCQGEbu837ebU0LuJku7f98sPME9GWFspGB/EBNcEoz7mF/TbEBEN8CZpU8zW20 aUharQQlq8x01p5v0EmecD2LbmoVFVTryMuAHQDeV/rjGjrR7nKW0JWbKjTJZOXkBXZ8 0RdksorNxEYPQziot4Y/18k4rxLdZVsMKBlfTzstFmT7wzzeDn191CSyXMrftIkwooO/ IMzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ikbis2EmZPHbVV90StLUr/aGwCPiufobBGQ1XGXra5o=; b=OlWTq6GvzZfgrlHh1ZN5qvDNrr0AjkpeuLXpmQDkA3Iv96RWYVWIP9AH9SS9cPg/CQ 5pSTjxazVGd0NZiXESITWHTS6DmXT+1Amac5k/WZKCnibCQ83QoK2ML4YWWYxtZ8OGmZ LaI4rp+F1wTxS5rhzrBcxCLsolG27EMZWkNGy1PC/0qBOx4ZM2iG4JyjJevsXfa+x2Fv RhlBEdTRC3Pn71oBW+LQ42bR07Ie0u9eFElBZm57udmMSBMVb7EqKwdbyIETZBsH++ev ikLpOpIZNd/qAIqZG9MCBySlwQH/K+9Ovp7SyZhz5RRySzCDe/c+fhSJAAIDVcTCu/Ub xKLw== X-Gm-Message-State: APjAAAWylEOePBGiRPTj5H1THzDPempIZDthabkpfFrUDRNFn0K8R9IN YJArJBHUTPS77oPblqJoFupIaZyU X-Google-Smtp-Source: APXvYqwWNh1KZRI3lvx9Z6vzN5xOr8jBaOerQ0dJf5ON01ofGkvv2hdtzX9ZUNNGCpV18Du2MZNARA== X-Received: by 2002:a1c:6745:: with SMTP id b66mr5087014wmc.30.1571925870752; Thu, 24 Oct 2019 07:04:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 30/39] hw/i386/pc: Remove kvm_i386.h include Date: Thu, 24 Oct 2019 16:03:46 +0200 Message-Id: <1571925835-31930-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 By extracting pc_gsi_create() and pc_i8259_create() we removed the access to "kvm_i386.h" from the machine code. We can now remove it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191015162705.28087-25-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 1 - 2 files changed, 2 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 648dc9a..3a4a64a 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -57,7 +57,6 @@ #endif #include "migration/global_state.h" #include "migration/misc.h" -#include "kvm_i386.h" #include "sysemu/numa.h" =20 #define MAX_IDE_BUS 2 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 157d1da..def3bc2 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -36,7 +36,6 @@ #include "hw/timer/mc146818rtc.h" #include "hw/xen/xen.h" #include "sysemu/kvm.h" -#include "kvm_i386.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h" --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931713; cv=none; d=zoho.com; s=zohoarc; b=it7Eoh+ZMkcUzCtUrm/sL608dkipWtsoz4tI47Wz+9gh5SE8YFd2gaNhTQk+FRES8otH/9AcFSY5QiV7v2kLSvu8jLT1u2UGlD33i47kSQ/0zbvmLF+VpQIN7qHxVBpXd7w3jo9J5wvL5lk5yc/q47ubUqknfVz6RzSAtONYe/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931713; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bW6P2NgO+nuwZAStwk4n4lKvUPFNwzLT5MNnpnO4GMQ=; b=n0dGqD1JyEfMvA9/P1E0kseuUHcqobly6BeP6UdftJVGtbb+B4SrFn9Ybq6vcLUJvoh32ZHdLDhySeZF6p0+67KBSDNPGKgENP/6OYnESoF5KMEFPFjHhQUPnmkckmxnhGoG3cMToi+ZIDBKxTLMggpJUuPGX+3HVgyB9CmVQeo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931713272376.76431090236383; Thu, 24 Oct 2019 08:41:53 -0700 (PDT) Received: from localhost ([::1]:45534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfFI-0002jg-54 for importer@patchew.org; Thu, 24 Oct 2019 11:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35006) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjD-0008Ii-Or for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj7-0007qV-D1 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:38 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj7-0007pT-6h for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:33 -0400 Received: by mail-wr1-x42e.google.com with SMTP id p4so26247263wrm.8 for ; Thu, 24 Oct 2019 07:04:33 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bW6P2NgO+nuwZAStwk4n4lKvUPFNwzLT5MNnpnO4GMQ=; b=ZAuE0g5h1/sf6lx7tbMjIzenhYtXPfDQUHtzmTcXzEGe+2hb+KOFhz8ZNJqwmEawz/ qpTlBNbQSmc1ycUav4M/hoQH/H9RNCcHGsaUM7l66rscTL59Ri0zb6D4dNxNHWtQORBw 6qwKOfOupZy0GS9vk0UvQnCvq/5zi/2Geh30isPTJQoYl8WyXiPWst30MnxHjfJJTDan GUJfGAiRpbXdTNrsJFY7sTgkHCG0AoSl2VSvouRQheQjTdCeYP7h0HxhqzNAOxxMtT8V yCyeuRQUzRjsvC9cdIMqlXwK34cvFdP/2sUHihcWFrxRw2Ao3xY0mQintm9L0vvSu0O4 65fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=bW6P2NgO+nuwZAStwk4n4lKvUPFNwzLT5MNnpnO4GMQ=; b=FZVy+IrDcOo+wTUWQpjNVDkQEQLXWuKH+8MGMC2eyv3SYEqR9l3usg4uNKGYqFW4/D Cchp6VLIL+dY3T4b0MlFx/vHAfiOMe6badcKOBR2bQZKJpa1tcOEP9SijcxoZ8RqkHV9 pKrr4XbFTRCebhPNSa+6Sdiu49BjaPcZt2lH/xPYUtOTxoo9VflG6YT1icIOXGfxMbKc Gw1+h+KEYfq7/6PbBrHKLc1P77fVGqcWP/X5MVY83RTcsZKfEldl3KL3WXxBFTdtLfjO qoHrqD8pUy54fDPUdWwjHtGYolwkChMsqqCHIT+g5SnfchnwViZZI+JoCe9bXoCf/IYX nRmg== X-Gm-Message-State: APjAAAW6hlMw2AywFGKhemlvog9GURBf9DMYtNk/aXgdZTQ0pXSc/ESj uwDkJcZB1I7v4vtuiCCWf5thmeE1 X-Google-Smtp-Source: APXvYqztTibCuTQvi2u9iQrk872E+KxXKE3LNyVz1ZyQjNfGgxXOEZeqA1kFRahlXLVYkAXo0lXAuA== X-Received: by 2002:adf:9185:: with SMTP id 5mr4254381wri.389.1571925871860; Thu, 24 Oct 2019 07:04:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 31/39] mc146818rtc: move structure to header file Date: Thu, 24 Oct 2019 16:03:47 +0200 Message-Id: <1571925835-31930-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Herv=C3=A9 Poussineau We are now able to embed a timer in another object. Acked-by: Michael S. Tsirkin Acked-by: Paolo Bonzini Signed-off-by: Herv=C3=A9 Poussineau Message-Id: <20171216090228.28505-4-hpoussin@reactos.org> Reviewed-by: Aleksandar Markovic Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018133547.10936-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/timer/mc146818rtc.c | 30 ------------------------------ include/hw/timer/mc146818rtc.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index c979db0..09edb93 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -71,36 +71,6 @@ #define RTC_CLOCK_RATE 32768 #define UIP_HOLD_LENGTH (8 * NANOSECONDS_PER_SECOND / 32768) =20 -#define MC146818_RTC(obj) OBJECT_CHECK(RTCState, (obj), TYPE_MC146818_RTC) - -typedef struct RTCState { - ISADevice parent_obj; - - MemoryRegion io; - MemoryRegion coalesced_io; - uint8_t cmos_data[128]; - uint8_t cmos_index; - int32_t base_year; - uint64_t base_rtc; - uint64_t last_update; - int64_t offset; - qemu_irq irq; - int it_shift; - /* periodic timer */ - QEMUTimer *periodic_timer; - int64_t next_periodic_time; - /* update-ended timer */ - QEMUTimer *update_timer; - uint64_t next_alarm_time; - uint16_t irq_reinject_on_ack_count; - uint32_t irq_coalesced; - uint32_t period; - QEMUTimer *coalesced_timer; - LostTickPolicy lost_tick_policy; - Notifier suspend_notifier; - QLIST_ENTRY(RTCState) link; -} RTCState; - static void rtc_set_time(RTCState *s); static void rtc_update_time(RTCState *s); static void rtc_set_cmos(RTCState *s, const struct tm *tm); diff --git a/include/hw/timer/mc146818rtc.h b/include/hw/timer/mc146818rtc.h index fe6ed63..0f1c886 100644 --- a/include/hw/timer/mc146818rtc.h +++ b/include/hw/timer/mc146818rtc.h @@ -1,10 +1,43 @@ #ifndef MC146818RTC_H #define MC146818RTC_H =20 +#include "qapi/qapi-types-misc.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "hw/isa/isa.h" #include "hw/timer/mc146818rtc_regs.h" =20 #define TYPE_MC146818_RTC "mc146818rtc" +#define MC146818_RTC(obj) OBJECT_CHECK(RTCState, (obj), TYPE_MC146818_RTC) + +typedef struct RTCState { + ISADevice parent_obj; + + MemoryRegion io; + MemoryRegion coalesced_io; + uint8_t cmos_data[128]; + uint8_t cmos_index; + int32_t base_year; + uint64_t base_rtc; + uint64_t last_update; + int64_t offset; + qemu_irq irq; + int it_shift; + /* periodic timer */ + QEMUTimer *periodic_timer; + int64_t next_periodic_time; + /* update-ended timer */ + QEMUTimer *update_timer; + uint64_t next_alarm_time; + uint16_t irq_reinject_on_ack_count; + uint32_t irq_coalesced; + uint32_t period; + QEMUTimer *coalesced_timer; + Notifier clock_reset_notifier; + LostTickPolicy lost_tick_policy; + Notifier suspend_notifier; + QLIST_ENTRY(RTCState) link; +} RTCState; =20 ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931230; cv=none; d=zoho.com; s=zohoarc; b=Vm22qd8rB7fc8yiEIUr6pvXbl1f9TgvQSLvGnWOE91DQ9+s4ORBsyVhaFw/+xcLrVmx1dUM9mFur4uvR8WWZmwEZ79J5aLZWoFUaqyapd8jIeQrYW74CgI/CjppfbV/Ikd7tHrDifIKcCG31HyewemSHjXh7AIo1OrTDQp3mxNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931230; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xgA/nfPYbU/wnzE4LWtTg2UNcRZThw4UJ6slzE0LxoU=; b=S46FsK3zRDWffnBH/uHPkT+KJS1NKR8/QAqcjymbSL+X+4rWYWyFCAB9cQEiOzdGGZ1yQL56sz97HIi7SEENgTA16QFar2bxI/3kU6SMFHMoWZpmS0zPfnrkIxHn6bKAVVvV/Txw686qhMflAJbaWqBzejuHC1ueVKMgiJBYRMs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931230590817.0418928289848; Thu, 24 Oct 2019 08:33:50 -0700 (PDT) Received: from localhost ([::1]:45452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf7V-0001gS-5B for importer@patchew.org; Thu, 24 Oct 2019 11:33:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34958) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjA-0008Cw-0c for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj8-0007rf-Ie for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:35 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:43856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj8-0007qe-Bs for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:34 -0400 Received: by mail-wr1-x434.google.com with SMTP id c2so21003643wrr.10 for ; Thu, 24 Oct 2019 07:04:34 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xgA/nfPYbU/wnzE4LWtTg2UNcRZThw4UJ6slzE0LxoU=; b=LbMyW7bKdslaII83GV1xbLROtaD+ZotfiirSUVD6vJceeKbss9ykHyWY76DHQkzb0v XA0+h3YzwhginXpGBGSbXJ/uCeBUpnrJ9POhoYIbdSqavtLxq/ZJ5SELoRziAnASR9QF IWnMcLUyhFgML4IdiMhUXT50eyUApRgvr3C8VzV76BAi9ICNSdXAzLaCN+H/fq1+mu9E K6JwA0OrJfvC5ZJ0Gd/3J8rPd5gtPedWe1z4nE/WGayU0KC+AsC8K35yrb8HuDcGMNEZ imclijIqlHfgCsKaMkOSokWftwCOyxUcbr6lwcoWu5tvmgseo/tVh7zPAYxdU7zwhW2f QgOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xgA/nfPYbU/wnzE4LWtTg2UNcRZThw4UJ6slzE0LxoU=; b=AYHqkkS31fVG71YoFJl3Fgnn0lmXzH9aOSM+gAnE9DL4+27ZOw+XCm7Zy44iwIm8t4 k8JRtv9Rp+uZ37Epujq3s0XtU55KqDnM5uJhGU0eqq0nYsLOB576RJdE35q1Kjnw2tqu Ll6tcOIxh26JS5ISqZiZSZ89NoL5nRgKp/5bspIUunnMfq027ZnlSjqAk/Fzid5q30Of jZ2BD51BJBZzalwGbt5a4ooAJrn1GrPnwNygANX0GELE1qiMYCDJB5Zws8RF63db5+VY Qa5QvpP1FLdD90Z9XSrP56wUQKfX2Hcmm1z4YlaERxD+1ZuUh2sfDZgXnwKTx5pf1P9x MVJg== X-Gm-Message-State: APjAAAXgieRbzd/3Hsm7u2kKfv4n7nUjwUgOtMTba3mWDYPKJSiQI5kJ xqS4Omrq/fLK0zAVNx3lbEsvfwyU X-Google-Smtp-Source: APXvYqzjj66oYe4cundTg3pmDCwXXDMiAMALKxgoMd1F72ypDGL6L/VT1cbtB0gzBcp5SgsZMSscag== X-Received: by 2002:a05:6000:11cd:: with SMTP id i13mr3899820wrx.197.1571925872989; Thu, 24 Oct 2019 07:04:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 32/39] mc146818rtc: Move RTC_ISA_IRQ definition Date: Thu, 24 Oct 2019 16:03:48 +0200 Message-Id: <1571925835-31930-33-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The ISA default number for the RTC devices is not related to its registers neither. Move this definition to "hw/timer/mc146818rtc.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018133547.10936-3-philmd@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/timer/mc146818rtc.h | 2 ++ include/hw/timer/mc146818rtc_regs.h | 2 -- tests/rtc-test.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/hw/timer/mc146818rtc.h b/include/hw/timer/mc146818rtc.h index 0f1c886..17761cf 100644 --- a/include/hw/timer/mc146818rtc.h +++ b/include/hw/timer/mc146818rtc.h @@ -39,6 +39,8 @@ typedef struct RTCState { QLIST_ENTRY(RTCState) link; } RTCState; =20 +#define RTC_ISA_IRQ 8 + ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq); void rtc_set_memory(ISADevice *dev, int addr, int val); diff --git a/include/hw/timer/mc146818rtc_regs.h b/include/hw/timer/mc14681= 8rtc_regs.h index bfbb57e..631f71c 100644 --- a/include/hw/timer/mc146818rtc_regs.h +++ b/include/hw/timer/mc146818rtc_regs.h @@ -27,8 +27,6 @@ =20 #include "qemu/timer.h" =20 -#define RTC_ISA_IRQ 8 - #define RTC_SECONDS 0 #define RTC_SECONDS_ALARM 1 #define RTC_MINUTES 2 diff --git a/tests/rtc-test.c b/tests/rtc-test.c index 6309b0e..18f8956 100644 --- a/tests/rtc-test.c +++ b/tests/rtc-test.c @@ -15,6 +15,7 @@ =20 #include "libqtest-single.h" #include "qemu/timer.h" +#include "hw/timer/mc146818rtc.h" #include "hw/timer/mc146818rtc_regs.h" =20 #define UIP_HOLD_LENGTH (8 * NANOSECONDS_PER_SECOND / 32768) --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571926694; cv=none; d=zoho.com; s=zohoarc; b=VsbQRdBUF4Aw5ququevBQkU77+47qzBLoeSB+wP8WIy9ArR74lPC2yBdlS52gaUCsqi6ptoVbuXuY8TYuop/063Rm38+3ZA9ZvdtI/3vBbyZSd1TnZlsGndTlfRZ5eRLkdRwpNWHkuuR0vtUMYZQugUp6oICCMg/2bQAJ6ZCDmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571926694; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DDYGyaLmE3BDNJATtq1uXRqF7WOHQrSKzbLNf8DRnU4=; b=cqYzNDnMQy/Ost60qjbf5FJatxtLT50vPrK6Bnx0/H5QY2K50SjkEghSbKEE7keyR/HH7vkyhZR4U8KszhtgXIIv5HWqBKWUBDcr2+V6vQVu4Zhb9FIdG6LNUOEb9XfhjtqJorOPUiNyU0HOXtCzhq4cPFzpOP3I1uQWUuYiM9M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15719266945766.349306330710078; Thu, 24 Oct 2019 07:18:14 -0700 (PDT) Received: from localhost ([::1]:43814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdwL-0002Z4-0E for importer@patchew.org; Thu, 24 Oct 2019 10:18:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34971) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjA-0008Ek-Qi for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdj9-0007s8-M0 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:36 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:36481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdj9-0007rq-Ey for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id c22so2747571wmd.1 for ; Thu, 24 Oct 2019 07:04:35 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DDYGyaLmE3BDNJATtq1uXRqF7WOHQrSKzbLNf8DRnU4=; b=KSPjoF7YphRGHDA5M4aW1CfRFb8rv6dWweYc9JOWBBKCkAs31ZKSn054FG/fYFgTuE DlUfqzNZ/e39poNqYpd857b+ZgF1XCj6obY/Em4tYMBIN7U/HYJti18BCkFVUNNN8rhv 5MgEqNG6M2Fgjryc+8oknarMM1X9RzEeYNQdcgR4jm97Gnfv0Eqp8yTT7EkI+9My5UZm YDLQRYRMd4OD2d7hWHmrfXMHiJNhCqqJuQu7n2fjo3Nkji6axAweG9eeQywRwvwZCgvF 2/X2Y4d7VTw0YO0vBM6vi0ywUvd86H6oylSP4M5VRJgkMw9ulGOv+rhpFWUYAUS2GFBQ v1zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DDYGyaLmE3BDNJATtq1uXRqF7WOHQrSKzbLNf8DRnU4=; b=dgdqlh9DabXp7RkhHc13fE7Nn71p7pk+llhQ6rKyWT50l8Hzy4WQF6UcLYaa9aGZN4 8B5uHd0n4zeXP+t8/WrnuhGWLQRyF39pVp/WIgFa6QvhV3CFL3s8XZSJlJ8Sat4znu4d aapfpSY6ltWBqyy6j26p/Y03XtJXCHz38i7un3Ta3IatWJrHjVXSpdlMHY1rNV2sp67z eBxfm5F2rXexhj3da70f3za6Ntbl0FAkqKJvhmkaArRn2FbK7QlRtSz3hqcZk4pqzbO0 fP4tHOmZQH6D1AM6C3cpCLbQEJa1UmAwaamWjX4x5PNgE3XirtZsZZKRHqlRAnmJZ7MU Jm1g== X-Gm-Message-State: APjAAAWff9kYlFcJDF1R9s/56VBpZ9pq41dAtN7WvvxCgwjBd0+61c8d xVD9C3gLxOggEtZX6PpPaQVG7JuL X-Google-Smtp-Source: APXvYqwgGiMGlJmNFlJBQhO0bNHC3eFg2SEGufh6lb2pmsiHD6kTZV0CwThuqVQWkR+S9GmvOBWumA== X-Received: by 2002:a05:600c:2503:: with SMTP id d3mr5469199wma.44.1571925874184; Thu, 24 Oct 2019 07:04:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 33/39] mc146818rtc: Include mc146818rtc_regs.h directly in mc146818rtc.c Date: Thu, 24 Oct 2019 16:03:49 +0200 Message-Id: <1571925835-31930-34-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Devices/boards wanting to use the MC146818 RTC don't need the knowledge its internal registers. Move the "mc146818rtc_regs.h" inclusion to mc146818rtc.c where it is required. We can not move this file from include/hw/timer/ to hw/timer/ for local inclusion because the ACPI FADT table use the RTC_CENTURY register address. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018133547.10936-4-philmd@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/timer/mc146818rtc.c | 1 + include/hw/timer/mc146818rtc.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 09edb93..dce4dae 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -40,6 +40,7 @@ #include "qapi/qapi-events-misc-target.h" #include "qapi/visitor.h" #include "exec/address-spaces.h" +#include "hw/timer/mc146818rtc_regs.h" =20 #ifdef TARGET_I386 #include "qapi/qapi-commands-misc-target.h" diff --git a/include/hw/timer/mc146818rtc.h b/include/hw/timer/mc146818rtc.h index 17761cf..a857dcd 100644 --- a/include/hw/timer/mc146818rtc.h +++ b/include/hw/timer/mc146818rtc.h @@ -5,7 +5,6 @@ #include "qemu/queue.h" #include "qemu/timer.h" #include "hw/isa/isa.h" -#include "hw/timer/mc146818rtc_regs.h" =20 #define TYPE_MC146818_RTC "mc146818rtc" #define MC146818_RTC(obj) OBJECT_CHECK(RTCState, (obj), TYPE_MC146818_RTC) --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927132; cv=none; d=zoho.com; s=zohoarc; b=kjaTqIxiFlWwE85YRU+YQXIZ22FialHvNgPDe+3rlhx81mqip8cyjxLDXkeCv2zGA6Vzw/BGfBNtHusWQXCllddJ/DBbEWPUsnXH3iCdgitmoC6vSOvJ9hIhWzt6Kz+94p2rMPPtSSonWUkvrwmPNdkyRhoZ5vSzfaudsRQpb/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927132; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TFNvMP30xKoxAS2yg65BboQPupWQoCvJdN+IX9nNhRA=; b=QdnKrgkzxOwDI/JtU1IC0d/M2H65V/5IwHBeQTkkJFiEkqnDWXyjy6rGKEQZTpxsZjCsSDOgecJ2s5V/nqVEk5ne7hFrLULdNU6anLacwWmrrYJBIKAv8s41lUG12Frpjbl/7u2Q2/CmwH8JAP9CBEsoz3BK5D9j3o7ANLjk87E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927132818222.91715686777957; Thu, 24 Oct 2019 07:25:32 -0700 (PDT) Received: from localhost ([::1]:44180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNe3P-0005Vq-8o for importer@patchew.org; Thu, 24 Oct 2019 10:25:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34990) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjB-0008Gj-VN for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjA-0007sf-Ko for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:41163) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjA-0007sE-EQ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:36 -0400 Received: by mail-wr1-x42b.google.com with SMTP id p4so26247502wrm.8 for ; Thu, 24 Oct 2019 07:04:36 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TFNvMP30xKoxAS2yg65BboQPupWQoCvJdN+IX9nNhRA=; b=KsLWphywSX1L6cyres/TN1Q3j2zhRs9rTPQFaJ9cslNvZXkpCodV3tIf82ap9gMO5F NCFU1LDCVJs2qOu8cwK9rW2xO+XMbBzBwvFTKSZuu2pPLGKv13xHCW1IuKrnD8XOru0E SkwGn2gUOs3auQ1sZSYkcLKcmmDgmBTjPqdgaN5A87+EFEJu/fAVJdgyRgip0CxW42n1 WPKDfI/b0ivFs2v2RFP66gRv8habcPbo4hnnqaaxBUUKqLlRpBm1yZyzk9GwRI1EqhE+ u595Qj7mDITmDU6qbq7YbgeePRQ1thscXEHaN4jXM/Q8Vzf6O0ZpuP8DeSJhMzh+SNGO ejBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TFNvMP30xKoxAS2yg65BboQPupWQoCvJdN+IX9nNhRA=; b=oRDH4/7GZrkduTIRlaTWEsdKA+QbO1cYPQI1Z0s+NlQjK+RdaYli/rDzSy8ZXkfvaq RlDvK5FQhw0LC2QeW/eIt5JQaQ8eMkiDkZhXIFHIDaecIjDfVujLAoDsR0kDC0TM4FTS DLBF3E195sRszkuR7odKwtJk0O1f3FPvm/9ypgI5wfhNa/l3WEJKyKunZoHtTYGvt9Lw Vo4CstAHFZQZCPT+QThrAIjZCd4Rx+99yiSmUXm69zq+Ur92h3WffYfiif/Qh2MhVp1X X6QIdiPAs0To7wrMKtR1pzcPLC3IRiHgx8KmnbzBFcbHNJvc850tfDHS7EGPCD9cYbNf GZqA== X-Gm-Message-State: APjAAAUd6gqN9reSQW4hioCsR2GnRUQYknMXSTTz6tCAJFQTTJ9StBpl 6z/4bAt5SevaSf0JoK/orV7fYn0O X-Google-Smtp-Source: APXvYqztFrsNnrrGr7QkdaPYQE2E5Kh+CcCetQXHY3GRZK5e6nhQ8e+ex9lHLiqv2tv0enQtsV2oeQ== X-Received: by 2002:a5d:674f:: with SMTP id l15mr4391648wrw.80.1571925875139; Thu, 24 Oct 2019 07:04:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 34/39] mc146818rtc: always register rtc to rtc list Date: Thu, 24 Oct 2019 16:03:50 +0200 Message-Id: <1571925835-31930-35-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Herv=C3=A9 Poussineau We are not required anymore to use rtc_init() function. Acked-by: Michael S. Tsirkin Acked-by: Paolo Bonzini Signed-off-by: Herv=C3=A9 Poussineau Message-Id: <20171216090228.28505-5-hpoussin@reactos.org> [PMD: rebased, fix OBJECT() value] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191018133547.10936-5-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/timer/mc146818rtc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index dce4dae..0d7784b 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -964,17 +964,16 @@ static void rtc_realizefn(DeviceState *dev, Error **e= rrp) object_property_add_tm(OBJECT(s), "date", rtc_get_date, NULL); =20 qdev_init_gpio_out(dev, &s->irq, 1); + QLIST_INSERT_HEAD(&rtc_devices, s, link); } =20 ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercep= t_irq) { DeviceState *dev; ISADevice *isadev; - RTCState *s; =20 isadev =3D isa_create(bus, TYPE_MC146818_RTC); dev =3D DEVICE(isadev); - s =3D MC146818_RTC(isadev); qdev_prop_set_int32(dev, "base_year", base_year); qdev_init_nofail(dev); if (intercept_irq) { @@ -982,9 +981,8 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year= , qemu_irq intercept_irq) } else { isa_connect_gpio_out(isadev, 0, RTC_ISA_IRQ); } - QLIST_INSERT_HEAD(&rtc_devices, s, link); =20 - object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(s), + object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(isade= v), "date", NULL); =20 return isadev; @@ -1016,8 +1014,6 @@ static void rtc_class_initfn(ObjectClass *klass, void= *data) dc->reset =3D rtc_resetdev; dc->vmsd =3D &vmstate_rtc; dc->props =3D mc146818rtc_properties; - /* Reason: needs to be wired up by rtc_init() */ - dc->user_creatable =3D false; } =20 static const TypeInfo mc146818rtc_info =3D { --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571929690; cv=none; d=zoho.com; s=zohoarc; b=iC0OuBHuGut+LdXrJAK1DiTpmLqEgIp9XcbwT+roGpbG4xnCY8wT/S0AwB14ldSfggqrj3N4NyHyvwX48Da72vTPjsBSi6IbfFRgPP4f43sTLZ9AZLBLSCir5p5R7HI6W9hMXD/2k7/5oeoAZuXvIGUba+TZACeImbD2UtLFxmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571929690; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=tKEZ3xBORUH745lD3K4++eyOpvEvcJPLpryLwnDHKcA=; b=lXFqwoUGwoUpaHX7IDBR18sDdgPMGcbyl+ap2HAck552P1dbW1MpyGM2TLb2Juu83yjfY2RBtt894vt7GFsk7AoCVZSgp/h+NppGKQM3cPBhRDoPbOjf0brua2qbe5t6MXTrUTzW8KlQyzgedtbDmDWgDuPqtj7EULSxL1r8iw4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571929690175351.08215134282614; Thu, 24 Oct 2019 08:08:10 -0700 (PDT) Received: from localhost ([::1]:45152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeif-0001Yb-0g for importer@patchew.org; Thu, 24 Oct 2019 11:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35003) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjD-0008IW-Li for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjB-0007tb-I3 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:38 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:36888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjB-0007tE-C7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:37 -0400 Received: by mail-wr1-x42d.google.com with SMTP id e11so17538969wrv.4 for ; Thu, 24 Oct 2019 07:04:37 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=tKEZ3xBORUH745lD3K4++eyOpvEvcJPLpryLwnDHKcA=; b=KlYALKahNrJgFupyMnWGV0LlYr32drx9DnG/SugQq6IuVOVVjRaWxWpEGDO1XbhjFC keugCdxBvjG5HmVg6dpx4HKuTfXECz1KuMALAnPl59mELmoLQvumifgoOc/siIAg+idl 318wjDZbc6QTr+EHdm9JEIMXuvKGNmZS61D1WZETZOTuYc037mHVHAhTaHkIXrSnw5y/ +5E1HyKTsuRxyVea7ZTJcgDQB0xwE97oHkkiZJeI6+ITBK7hwGz+r0ohzlucDetv11t3 28QudQkeS7FqssnX9PkhmdoSGOBlnNL7D3SdPLldYLTlCmjwhhdbgs4JXJ43VSpR1uGb PI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=tKEZ3xBORUH745lD3K4++eyOpvEvcJPLpryLwnDHKcA=; b=O5BdOjO7l5r7HkgbAF0mTCczu91/hd+47wC0R9Z+3NbWBu9NqhacONUXJPcNdO9nWF gkE818xdPPcgqGaJs+I968NRPyVaczxXy8y7POAbP+O1YzhZnmd+7hNPzolukoq4jom/ XyrfeOpIUVPqz3CUAAh0BphNNqGfRh26wh3KAGP7Z1/LSRyJdUUkM+2DymMhpqaUoMBg kkuXl/+ve+FpLn+nf0SKzAQuwMh662ca2SHb03mUq+ziXqcdFy2/7/ZMflTQxoLKmLfI bk/BkK8tuAwQ8CH1fExwLxbxb7jHhkN5ogC0A68iX1mM56SSVWJpNFQjUP9kX1aK1gEn d0Dg== X-Gm-Message-State: APjAAAXX5YcsziPX0pCYe1YswdbWnqy4LWNjsUD+/gcOybAbNbjW6uzS 8Lt13wAHsE8quY4Jy0wstbhPcLM5 X-Google-Smtp-Source: APXvYqxnVvBj2e5TpYey+vMYgfaOnlGHnVomlb65E2bZN3wJr/Wsage04i80XZzjZehgmA/Zp1v1xw== X-Received: by 2002:a5d:424a:: with SMTP id s10mr3904767wrr.108.1571925876167; Thu, 24 Oct 2019 07:04:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 35/39] audio: fix missing break Date: Thu, 24 Oct 2019 16:03:51 +0200 Message-Id: <1571925835-31930-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reported by Coverity (CID 1406449). Signed-off-by: Paolo Bonzini --- audio/paaudio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index df541a7..55a91f8 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -385,6 +385,7 @@ static pa_stream *qpa_simple_new ( map.map[5] =3D PA_CHANNEL_POSITION_REAR_RIGHT; map.map[6] =3D PA_CHANNEL_POSITION_SIDE_LEFT; map.map[7] =3D PA_CHANNEL_POSITION_SIDE_RIGHT; + break; =20 default: dolog("Internal error: unsupported channel count %d\n", ss->channe= ls); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571932236; cv=none; d=zoho.com; s=zohoarc; b=kKq1F6EG5QLnB0VjJ1tgxjh0AqRfPmVmG2l9p36uaoUnGZeRUIqh4f2CxhE/pS2fUxOUA7GKFjqPYb4IH5fa3Jd/Hc2wV+TI9OYUHxLdcwnC/UVneDpDTMpXJwre61U9pfilxBx5zHGWnEL/xNAoOeNAfDU5/WTDmgfsCqyOmcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571932236; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2ljGpKGl/qkz79Gqkva+tRZiiwcaLrJvFEeqtn6BdMA=; b=mPUcrjvdQqBjBFYT6s+LwUMED35eZf1waQXeHbS1QzXAmY6KV0ol8bV/1SUZz1iHUh06KW5xKaQwZAKRG1ICuNH4KDiiLoByFLq1Lrjx3WHix8BfdroEwL2s5yx5ahOLZa8CrPNteIWGWYiRVEVQgK2J5aHBoshcPv46dDxePVA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571932236555717.9923575921284; Thu, 24 Oct 2019 08:50:36 -0700 (PDT) Received: from localhost ([::1]:45652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfNi-0007iO-EC for importer@patchew.org; Thu, 24 Oct 2019 11:50:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35067) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjJ-0008Tc-VB for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjD-0007wD-8h for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:45 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjC-0007vK-Rr for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:39 -0400 Received: by mail-wr1-x441.google.com with SMTP id r1so16440008wrs.9 for ; Thu, 24 Oct 2019 07:04:38 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ljGpKGl/qkz79Gqkva+tRZiiwcaLrJvFEeqtn6BdMA=; b=F5cjbjQ1LRxmSUGRqMJ1TCG+liiOegUKzdnB8cDH2YFu4tsgRKSXPnE5q4l/ZaLiMv 8wqkydtkDCreuiAp09ZnxTdOTYWlS6vH5ygj5ET3/BXFWGv7w8osTq4jTt5HRG9mPizc iIYytTFx3BdJx3oYVx3z9Ls/QgndQh4ADWxqk2qsn3wXHZiEIbT0pbziC3e+sRk6SO1C FfZn/7sqme16JhLWSCCxIt0wOw2ZJiZedsfgnqDYsaRxOoKLAsEgHg17V/Dg96Kp37pL GFeK+i7MQ8ArAlUexj9xJGMev1zryKnv7aA8taQr63Z1U4mNFQQDswrkiNz80OhNNLAg 504Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2ljGpKGl/qkz79Gqkva+tRZiiwcaLrJvFEeqtn6BdMA=; b=FlvaBTGyNXW4+eTA+9wnwowYTIZzlWwSlpqq0KYkgc4vU6vNliP1+wqM8RxqykO99d ewY+KoFS1w6MvYSsptSU6SjZ8h7e4lbXVz8sWkU9+aGqwKDbqlR5VcSJiQrLohIH8Dw7 U5TncTZAuoQyJoP1iqIEiLUbT6RDYIzdhNxxSfJa3bhXz2dtz4cOMQJsk7tKAkQXglF0 G0KUCTL7d63Qzr/nVYKnaQAV8b6kvfkFPhls+0v+SEpY3PFPtxRZJf0E2IiKr6iiL6aE XNs/aqOw+onLctcUJWaUUGU8j1J1yOrTh9fRo9dloqXk6WIeiwUJzi6B9nBozWqllk6q EvYQ== X-Gm-Message-State: APjAAAXtO77SB8D97wb1Ji/nZ5c3FUE6m4rDWqXkgDCv48FRBBuC0t0a ONPSM5Gq1WXZMF21T30t9I9Ml8DH X-Google-Smtp-Source: APXvYqxT+6ktJB1OVVyDUZG/geo5/MSM8uoDjGWrA+GdNFJpxPlwsKJbwW87EmxTDQN/8LVMFVEZ4A== X-Received: by 2002:adf:e9c7:: with SMTP id l7mr4056875wrn.57.1571925877164; Thu, 24 Oct 2019 07:04:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 36/39] core: replace getpagesize() with qemu_real_host_page_size Date: Thu, 24 Oct 2019 16:03:52 +0200 Message-Id: <1571925835-31930-37-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Yang There are three page size in qemu: real host page size host page size target page size All of them have dedicate variable to represent. For the last two, we use the same form in the whole qemu project, while for the first one we use two forms: qemu_real_host_page_size and getpagesize(). qemu_real_host_page_size is defined to be a replacement of getpagesize(), so let it serve the role. [Note] Not fully tested for some arch or device. Signed-off-by: Wei Yang Message-Id: <20191013021145.16011-3-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 6 +++--- backends/hostmem.c | 2 +- block.c | 4 ++-- block/file-posix.c | 9 +++++---- block/io.c | 2 +- block/parallels.c | 2 +- block/qcow2-cache.c | 2 +- contrib/vhost-user-gpu/vugbm.c | 2 +- exec.c | 6 +++--- hw/intc/s390_flic_kvm.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/rdma/vmw/pvrdma_main.c | 2 +- hw/vfio/spapr.c | 7 ++++--- include/exec/ram_addr.h | 2 +- include/qemu/osdep.h | 4 ++-- migration/migration.c | 2 +- migration/postcopy-ram.c | 4 ++-- monitor/misc.c | 2 +- target/ppc/kvm.c | 2 +- tests/vhost-user-bridge.c | 8 ++++---- util/mmap-alloc.c | 10 +++++----- util/oslib-posix.c | 4 ++-- util/oslib-win32.c | 2 +- util/vfio-helpers.c | 12 ++++++------ 25 files changed, 52 insertions(+), 50 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index d2d96d7..140b0bd 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -52,7 +52,7 @@ /* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We * need to use the real host PAGE_SIZE, as that's what KVM will use. */ -#define PAGE_SIZE getpagesize() +#define PAGE_SIZE qemu_real_host_page_size =20 //#define DEBUG_KVM =20 @@ -507,7 +507,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSe= ction *section, { ram_addr_t start =3D section->offset_within_region + memory_region_get_ram_addr(section->mr); - ram_addr_t pages =3D int128_get64(section->size) / getpagesize(); + ram_addr_t pages =3D int128_get64(section->size) / qemu_real_host_page= _size; =20 cpu_physical_memory_set_dirty_lebitmap(bitmap, start, pages); return 0; @@ -1841,7 +1841,7 @@ static int kvm_init(MachineState *ms) * even with KVM. TARGET_PAGE_SIZE is assumed to be the minimum * page size for the system though. */ - assert(TARGET_PAGE_SIZE <=3D getpagesize()); + assert(TARGET_PAGE_SIZE <=3D qemu_real_host_page_size); =20 s->sigmask_len =3D 8; =20 diff --git a/backends/hostmem.c b/backends/hostmem.c index 6d333dc..e773bdf 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -304,7 +304,7 @@ size_t host_memory_backend_pagesize(HostMemoryBackend *= memdev) #else size_t host_memory_backend_pagesize(HostMemoryBackend *memdev) { - return getpagesize(); + return qemu_real_host_page_size; } #endif =20 diff --git a/block.c b/block.c index dad5a3d..4cffc2b 100644 --- a/block.c +++ b/block.c @@ -106,7 +106,7 @@ size_t bdrv_opt_mem_align(BlockDriverState *bs) { if (!bs || !bs->drv) { /* page size or 4k (hdd sector size) should be on the safe side */ - return MAX(4096, getpagesize()); + return MAX(4096, qemu_real_host_page_size); } =20 return bs->bl.opt_mem_alignment; @@ -116,7 +116,7 @@ size_t bdrv_min_mem_align(BlockDriverState *bs) { if (!bs || !bs->drv) { /* page size or 4k (hdd sector size) should be on the safe side */ - return MAX(4096, getpagesize()); + return MAX(4096, qemu_real_host_page_size); } =20 return bs->bl.min_mem_alignment; diff --git a/block/file-posix.c b/block/file-posix.c index 695fcf7..5d1995a 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -327,7 +327,7 @@ static void raw_probe_alignment(BlockDriverState *bs, i= nt fd, Error **errp) { BDRVRawState *s =3D bs->opaque; char *buf; - size_t max_align =3D MAX(MAX_BLOCKSIZE, getpagesize()); + size_t max_align =3D MAX(MAX_BLOCKSIZE, qemu_real_host_page_size); size_t alignments[] =3D {1, 512, 1024, 2048, 4096}; =20 /* For SCSI generic devices the alignment is not really used. @@ -1136,13 +1136,14 @@ static void raw_refresh_limits(BlockDriverState *bs= , Error **errp) =20 ret =3D sg_get_max_segments(s->fd); if (ret > 0) { - bs->bl.max_transfer =3D MIN(bs->bl.max_transfer, ret * getpage= size()); + bs->bl.max_transfer =3D MIN(bs->bl.max_transfer, + ret * qemu_real_host_page_size); } } =20 raw_probe_alignment(bs, s->fd, errp); bs->bl.min_mem_alignment =3D s->buf_align; - bs->bl.opt_mem_alignment =3D MAX(s->buf_align, getpagesize()); + bs->bl.opt_mem_alignment =3D MAX(s->buf_align, qemu_real_host_page_siz= e); } =20 static int check_for_dasd(int fd) @@ -1705,7 +1706,7 @@ static int allocate_first_block(int fd, size_t max_si= ze) size_t write_size =3D (max_size < MAX_BLOCKSIZE) ? BDRV_SECTOR_SIZE : MAX_BLOCKSIZE; - size_t max_align =3D MAX(MAX_BLOCKSIZE, getpagesize()); + size_t max_align =3D MAX(MAX_BLOCKSIZE, qemu_real_host_page_size); void *buf; ssize_t n; int ret; diff --git a/block/io.c b/block/io.c index f0b86c1..e46d9e8 100644 --- a/block/io.c +++ b/block/io.c @@ -160,7 +160,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **= errp) bdrv_merge_limits(&bs->bl, &bs->file->bs->bl); } else { bs->bl.min_mem_alignment =3D 512; - bs->bl.opt_mem_alignment =3D getpagesize(); + bs->bl.opt_mem_alignment =3D qemu_real_host_page_size; =20 /* Safe default since most protocols use readv()/writev()/etc */ bs->bl.max_iov =3D IOV_MAX; diff --git a/block/parallels.c b/block/parallels.c index 7cd2714..f1dfb03 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -847,7 +847,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, } } =20 - s->bat_dirty_block =3D 4 * getpagesize(); + s->bat_dirty_block =3D 4 * qemu_real_host_page_size; s->bat_dirty_bmap =3D bitmap_new(DIV_ROUND_UP(s->header_size, s->bat_dirty_block)); =20 diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index d29b038..7444b9c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -74,7 +74,7 @@ static void qcow2_cache_table_release(Qcow2Cache *c, int = i, int num_tables) /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX void *t =3D qcow2_cache_get_table_addr(c, i); - int align =3D getpagesize(); + int align =3D qemu_real_host_page_size; size_t mem_size =3D (size_t) c->table_size * num_tables; size_t offset =3D QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; size_t length =3D QEMU_ALIGN_DOWN(mem_size - offset, align); diff --git a/contrib/vhost-user-gpu/vugbm.c b/contrib/vhost-user-gpu/vugbm.c index d3bb82f..9c357b6 100644 --- a/contrib/vhost-user-gpu/vugbm.c +++ b/contrib/vhost-user-gpu/vugbm.c @@ -52,7 +52,7 @@ struct udmabuf_create { static size_t udmabuf_get_size(struct vugbm_buffer *buf) { - return ROUND_UP(buf->width * buf->height * 4, getpagesize()); + return ROUND_UP(buf->width * buf->height * 4, qemu_real_host_page_size= ); } =20 static bool diff --git a/exec.c b/exec.c index fb0943c..9fc0d01 100644 --- a/exec.c +++ b/exec.c @@ -1756,11 +1756,11 @@ long qemu_maxrampagesize(void) #else long qemu_minrampagesize(void) { - return getpagesize(); + return qemu_real_host_page_size; } long qemu_maxrampagesize(void) { - return getpagesize(); + return qemu_real_host_page_size; } #endif =20 @@ -2417,7 +2417,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ra= m_addr_t max_size, new_block->max_length =3D max_size; assert(max_size >=3D size); new_block->fd =3D -1; - new_block->page_size =3D getpagesize(); + new_block->page_size =3D qemu_real_host_page_size; new_block->host =3D host; if (host) { new_block->flags |=3D RAM_PREALLOC; diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index cedccba..c9ee80e 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -25,7 +25,7 @@ #include "migration/qemu-file-types.h" #include "trace.h" =20 -#define FLIC_SAVE_INITIAL_SIZE getpagesize() +#define FLIC_SAVE_INITIAL_SIZE qemu_real_host_page_size #define FLIC_FAILED (-1UL) #define FLIC_SAVEVM_VERSION 1 =20 diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index c5bbcc7..3594517 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -439,7 +439,7 @@ static void ppc_core99_init(MachineState *machine) } =20 /* The NewWorld NVRAM is not located in the MacIO device */ - if (kvm_enabled() && getpagesize() > 4096) { + if (kvm_enabled() && qemu_real_host_page_size > 4096) { /* We can't combine read-write and read-only in a single page, so move the NVRAM out of ROM again for KVM */ nvram_addr =3D 0xFFE00000; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 01ff41d..191b295 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1942,7 +1942,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) * our memory slot is of page size granularity. */ if (kvm_enabled()) { - msi_window_size =3D getpagesize(); + msi_window_size =3D qemu_real_host_page_size; } =20 memory_region_init_io(&sphb->msiwindow, OBJECT(sphb), &spapr_msi_ops, = spapr, diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 3e36e13..3722d9e 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -601,7 +601,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **err= p) rdma_info_report("Initializing device %s %x.%x", pdev->name, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); =20 - if (TARGET_PAGE_SIZE !=3D getpagesize()) { + if (TARGET_PAGE_SIZE !=3D qemu_real_host_page_size) { error_setg(errp, "Target page size must be the same as host page s= ize"); return; } diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index e853eeb..33692fc 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -196,14 +196,15 @@ int vfio_spapr_create_window(VFIOContainer *container, * bits_per_level is a safe guess of how much we can allocate per leve= l: * 8 is the current minimum for CONFIG_FORCE_MAX_ZONEORDER and MAX_ORD= ER * is usually bigger than that. - * Below we look at getpagesize() as TCEs are allocated from system pa= ges. + * Below we look at qemu_real_host_page_size as TCEs are allocated from + * system pages. */ - bits_per_level =3D ctz64(getpagesize()) + 8; + bits_per_level =3D ctz64(qemu_real_host_page_size) + 8; create.levels =3D bits_total / bits_per_level; if (bits_total % bits_per_level) { ++create.levels; } - max_levels =3D (64 - create.page_shift) / ctz64(getpagesize()); + max_levels =3D (64 - create.page_shift) / ctz64(qemu_real_host_page_si= ze); for ( ; create.levels <=3D max_levels; ++create.levels) { ret =3D ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create); if (!ret) { diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index ad158bb..bed0554 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -373,7 +373,7 @@ static inline void cpu_physical_memory_set_dirty_lebitm= ap(unsigned long *bitmap, hwaddr addr; ram_addr_t ram_addr; unsigned long len =3D (pages + HOST_LONG_BITS - 1) / HOST_LONG_BITS; - unsigned long hpratio =3D getpagesize() / TARGET_PAGE_SIZE; + unsigned long hpratio =3D qemu_real_host_page_size / TARGET_PAGE_SIZE; unsigned long page =3D BIT_WORD(start >> TARGET_PAGE_BITS); =20 /* start address is aligned at the start of a word? */ diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index c7d242f..0f97d68 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -423,9 +423,9 @@ void qemu_anon_ram_free(void *ptr, size_t size); # define QEMU_VMALLOC_ALIGN (256 * 4096) #elif defined(__linux__) && defined(__sparc__) #include -# define QEMU_VMALLOC_ALIGN MAX(getpagesize(), SHMLBA) +# define QEMU_VMALLOC_ALIGN MAX(qemu_real_host_page_size, SHMLBA) #else -# define QEMU_VMALLOC_ALIGN getpagesize() +# define QEMU_VMALLOC_ALIGN qemu_real_host_page_size #endif =20 #ifdef CONFIG_POSIX diff --git a/migration/migration.c b/migration/migration.c index 3febd0f..4133ed2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2284,7 +2284,7 @@ static struct rp_cmd_args { static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rb= name, ram_addr_t start, size_t len) { - long our_host_ps =3D getpagesize(); + long our_host_ps =3D qemu_real_host_page_size; =20 trace_migrate_handle_rp_req_pages(rbname, start, len); =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index abccafc..a364027 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -308,7 +308,7 @@ static bool ufd_check_and_apply(int ufd, MigrationIncom= ingState *mis) return false; } =20 - if (getpagesize() !=3D ram_pagesize_summary()) { + if (qemu_real_host_page_size !=3D ram_pagesize_summary()) { bool have_hp =3D false; /* We've got a huge page */ #ifdef UFFD_FEATURE_MISSING_HUGETLBFS @@ -346,7 +346,7 @@ static int test_ramblock_postcopiable(RAMBlock *rb, voi= d *opaque) */ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { - long pagesize =3D getpagesize(); + long pagesize =3D qemu_real_host_page_size; int ufd =3D -1; bool ret =3D false; /* Error unless we change it */ void *testarea =3D NULL; diff --git a/monitor/misc.c b/monitor/misc.c index aef16f6..3baa15f 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -862,7 +862,7 @@ static uint64_t vtop(void *ptr, Error **errp) uint64_t pinfo; uint64_t ret =3D -1; uintptr_t addr =3D (uintptr_t) ptr; - uintptr_t pagesize =3D getpagesize(); + uintptr_t pagesize =3D qemu_real_host_page_size; off_t offset =3D addr / pagesize * sizeof(pinfo); int fd; =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 820724c..7d2e896 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -411,7 +411,7 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) * will be a normal mapping, not a special hugepage one used * for RAM. */ - if (getpagesize() < 0x10000) { + if (qemu_real_host_page_size < 0x10000) { error_setg(errp, "KVM can't supply 64kiB CI pages, which guest expec= ts"); } diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index c4e350e..6c3d490 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -468,8 +468,8 @@ vubr_queue_set_started(VuDev *dev, int qidx, bool start= ed) =20 if (started && vubr->notifier.fd >=3D 0) { vu_set_queue_host_notifier(dev, vq, vubr->notifier.fd, - getpagesize(), - qidx * getpagesize()); + qemu_real_host_page_size, + qidx * qemu_real_host_page_size); } =20 if (qidx % 2 =3D=3D 1) { @@ -594,7 +594,7 @@ static void *notifier_thread(void *arg) { VuDev *dev =3D (VuDev *)arg; VubrDev *vubr =3D container_of(dev, VubrDev, vudev); - int pagesize =3D getpagesize(); + int pagesize =3D qemu_real_host_page_size; int qidx; =20 while (true) { @@ -630,7 +630,7 @@ vubr_host_notifier_setup(VubrDev *dev) void *addr; int fd; =20 - length =3D getpagesize() * VHOST_USER_BRIDGE_MAX_QUEUES; + length =3D qemu_real_host_page_size * VHOST_USER_BRIDGE_MAX_QUEUES; =20 fd =3D mkstemp(template); if (fd < 0) { diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index f7f177d..27dcccd 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -48,7 +48,7 @@ size_t qemu_fd_getpagesize(int fd) #endif #endif =20 - return getpagesize(); + return qemu_real_host_page_size; } =20 size_t qemu_mempath_getpagesize(const char *mem_path) @@ -79,7 +79,7 @@ size_t qemu_mempath_getpagesize(const char *mem_path) #endif #endif =20 - return getpagesize(); + return qemu_real_host_page_size; } =20 void *qemu_ram_mmap(int fd, @@ -114,7 +114,7 @@ void *qemu_ram_mmap(int fd, */ flags =3D MAP_PRIVATE; pagesize =3D qemu_fd_getpagesize(fd); - if (fd =3D=3D -1 || pagesize =3D=3D getpagesize()) { + if (fd =3D=3D -1 || pagesize =3D=3D qemu_real_host_page_size) { guardfd =3D -1; flags |=3D MAP_ANONYMOUS; } else { @@ -123,7 +123,7 @@ void *qemu_ram_mmap(int fd, } #else guardfd =3D -1; - pagesize =3D getpagesize(); + pagesize =3D qemu_real_host_page_size; flags =3D MAP_PRIVATE | MAP_ANONYMOUS; #endif =20 @@ -205,7 +205,7 @@ void qemu_ram_munmap(int fd, void *ptr, size_t size) #if defined(__powerpc64__) && defined(__linux__) pagesize =3D qemu_fd_getpagesize(fd); #else - pagesize =3D getpagesize(); + pagesize =3D qemu_real_host_page_size; #endif munmap(ptr, size + pagesize); } diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f869338..5a291cc 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -617,7 +617,7 @@ void *qemu_alloc_stack(size_t *sz) #ifdef CONFIG_DEBUG_STACK_USAGE void *ptr2; #endif - size_t pagesz =3D getpagesize(); + size_t pagesz =3D qemu_real_host_page_size; #ifdef _SC_THREAD_STACK_MIN /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ long min_stack_sz =3D sysconf(_SC_THREAD_STACK_MIN); @@ -679,7 +679,7 @@ void qemu_free_stack(void *stack, size_t sz) unsigned int usage; void *ptr; =20 - for (ptr =3D stack + getpagesize(); ptr < stack + sz; + for (ptr =3D stack + qemu_real_host_page_size; ptr < stack + sz; ptr +=3D sizeof(uint32_t)) { if (*(uint32_t *)ptr !=3D 0xdeadbeaf) { break; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 886e400..e9b14ab 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -554,7 +554,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory,= int smp_cpus, Error **errp) { int i; - size_t pagesize =3D getpagesize(); + size_t pagesize =3D qemu_real_host_page_size; =20 memory =3D (memory + pagesize - 1) & -pagesize; for (i =3D 0; i < memory / pagesize; i++) { diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 26ffd0d..813f7ec 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -514,9 +514,9 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState= *s, IOVAMapping m =3D {.host =3D host, .size =3D size, .iova =3D iova}; IOVAMapping *insert; =20 - assert(QEMU_IS_ALIGNED(size, getpagesize())); - assert(QEMU_IS_ALIGNED(s->low_water_mark, getpagesize())); - assert(QEMU_IS_ALIGNED(s->high_water_mark, getpagesize())); + assert(QEMU_IS_ALIGNED(size, qemu_real_host_page_size)); + assert(QEMU_IS_ALIGNED(s->low_water_mark, qemu_real_host_page_size)); + assert(QEMU_IS_ALIGNED(s->high_water_mark, qemu_real_host_page_size)); trace_qemu_vfio_new_mapping(s, host, size, index, iova); =20 assert(index >=3D 0); @@ -567,7 +567,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IO= VAMapping *mapping, =20 index =3D mapping - s->mappings; assert(mapping->size > 0); - assert(QEMU_IS_ALIGNED(mapping->size, getpagesize())); + assert(QEMU_IS_ALIGNED(mapping->size, qemu_real_host_page_size)); assert(index >=3D 0 && index < s->nr_mappings); if (ioctl(s->container, VFIO_IOMMU_UNMAP_DMA, &unmap)) { error_setg(errp, "VFIO_UNMAP_DMA failed: %d", -errno); @@ -613,8 +613,8 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, IOVAMapping *mapping; uint64_t iova0; =20 - assert(QEMU_PTR_IS_ALIGNED(host, getpagesize())); - assert(QEMU_IS_ALIGNED(size, getpagesize())); + assert(QEMU_PTR_IS_ALIGNED(host, qemu_real_host_page_size)); + assert(QEMU_IS_ALIGNED(size, qemu_real_host_page_size)); trace_qemu_vfio_dma_map(s, host, size, temporary, iova); qemu_mutex_lock(&s->lock); mapping =3D qemu_vfio_find_mapping(s, host, &index); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571926928; cv=none; d=zoho.com; s=zohoarc; b=IlcWV2zkU4L7OHUxT+1Y/iRc/Ix1vmMqIl98MgieKy3lUnGwTxnHYIrP1uB4srjz/XwHH3IvVV/Wr2DXL3ruQbwXYnPvgiToWeYG36MQdge0rnulEML2H1voz2RP1k2jRxSLdkHHSTuhhaLVaLwV2iFlNfXi9NI/hGzV3CekXNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571926928; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+JOO2G3l+Owud+ib4UJhK6+M5ZCzXyr8Z3fX/8cawQs=; b=CLmoOozeRdfBWUETbeEDk2y4OqDU/kKtl1w3D7TNQ/2YZ96fipORKYUBvKnm0h+MN6ijfnt6syuYxY/OJTfDouRUxNfStUogQVo4t4dz6Nov7tueo7avD/XonSLhz+lO943rX+lrn/F54b4hpLXDQUJVzgwHwBrIYZddxQdowgg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571926928127311.05633287081946; Thu, 24 Oct 2019 07:22:08 -0700 (PDT) Received: from localhost ([::1]:43944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNe06-0007ZF-Bp for importer@patchew.org; Thu, 24 Oct 2019 10:22:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35028) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjF-0008Kd-8T for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjD-0007wo-Kb for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:40 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:42758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjD-0007vp-E0 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:39 -0400 Received: by mail-wr1-x42b.google.com with SMTP id r1so16440046wrs.9 for ; Thu, 24 Oct 2019 07:04:39 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=+JOO2G3l+Owud+ib4UJhK6+M5ZCzXyr8Z3fX/8cawQs=; b=Rh874hEMImHvCUinKoY58uOhIlpd26RjpBkxfheZuwKpM7dEtH8f6ktJmq6Xv14gD7 6huDg7GTW/mj9TZ+0cMnTsWUj5wuyLNcJLn4hZaM3bgyD69ZS5ZsCpvLwnypKKU1YyyZ xsjdCUTMv/gr2RFkrmgaIb4nK+nT0+IQrqtcu83ullhTFt6V9zVOs9KXP2VDd22Io1oU pZDvJMM9Phpqkr4prL5DRshdvSErS9pz0VF3UgUvI/HXILt9CxuEhNuiqw9vIHEVuHgX 9pWMua2Iy1PMFb+zchLWIfOCBJtyM+0+GF/ax/ct+JELVA6y2p38Zsj9Tu5eITMc6Cvg o5wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=+JOO2G3l+Owud+ib4UJhK6+M5ZCzXyr8Z3fX/8cawQs=; b=Yehds99ke23d6SgnddzacbD74QEDZsXgMvcRXBlLkCC5l/X+43k9o4plRH/N7LDBET Ma8JOrU4gDIY8ksGtKNMaK04Ku5zdWIvfpcB5Cjc8yHoPJTCshI/yfID99RVgDNPnNfN KQMLEju1JBIlM+/8moYgk0b/CoJ1x0yBYWpefs8xz8XOXMB8CNlebtueRtZJegQfJQys v8VeSSArqYjLdpFPg4yX/yfT9NIC9XKtqYl5XLrVi2atXQKqzsA3zlJ9PIbnI29fcud6 OVwzLYznkTsOXYQn+vOSWmlWrgFFj97qlpy7RBTs9ntF6NO8saVEE26F1SFKZdwsuT2s sklw== X-Gm-Message-State: APjAAAWbs9/Yu4oPvSSNLF7aVhuRVtv3/0Kzvz5R6bYjkHfVqJ4m4Uee GzbUszSL1cE9ozBTmTaa9VzaHIyb X-Google-Smtp-Source: APXvYqzt9naXrU4jurylrKsbn6tkRyYlh2bRY9+UxwaVgjItDeVISU16xFjBNZvP+rsy6aA6jHJcfg== X-Received: by 2002:a5d:638c:: with SMTP id p12mr3756502wru.136.1571925878013; Thu, 24 Oct 2019 07:04:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 37/39] target/i386: move FERR handling to target/i386 Date: Thu, 24 Oct 2019 16:03:53 +0200 Message-Id: <1571925835-31930-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move it out of pc.c since it is strictly tied to TCG. This is almost exclusively code movement, the next patch will implement IGNNE. Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 17 +++-------------- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- include/hw/i386/pc.h | 1 - target/i386/cpu.h | 3 ++- target/i386/fpu_helper.c | 26 +++++++++++++++++++++++++- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5fce60c..66d865b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -381,23 +381,12 @@ static uint64_t ioport80_read(void *opaque, hwaddr ad= dr, unsigned size) } =20 /* MSDOS compatibility mode FPU exception support */ -static qemu_irq ferr_irq; - -void pc_register_ferr_irq(qemu_irq irq) -{ - ferr_irq =3D irq; -} - -/* XXX: add IGNNE support */ -void cpu_set_ferr(CPUX86State *s) -{ - qemu_irq_raise(ferr_irq); -} - static void ioportF0_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { - qemu_irq_lower(ferr_irq); + if (tcg_enabled()) { + cpu_clear_ferr(); + } } =20 static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 3a4a64a..431d657 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -213,7 +213,7 @@ static void pc_init1(MachineState *machine, ioapic_init_gsi(gsi_state, "i440fx"); } =20 - pc_register_ferr_irq(x86ms->gsi[13]); + x86_register_ferr_irq(x86ms->gsi[13]); =20 pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index def3bc2..c9cdac8 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -261,7 +261,7 @@ static void pc_q35_init(MachineState *machine) ioapic_init_gsi(gsi_state, "q35"); } =20 - pc_register_ferr_irq(x86ms->gsi[13]); + x86_register_ferr_irq(x86ms->gsi[13]); =20 assert(pcms->vmport !=3D ON_OFF_AUTO__MAX); if (pcms->vmport =3D=3D ON_OFF_AUTO_AUTO) { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5923318..f040a72 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -176,7 +176,6 @@ void vmmouse_set_data(const uint32_t *data); extern int fd_bootchk; =20 bool pc_machine_is_smm_enabled(PCMachineState *pcms); -void pc_register_ferr_irq(qemu_irq irq); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); =20 void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b772e82..01e052b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1761,7 +1761,8 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env); =20 int cpu_get_pic_interrupt(CPUX86State *s); /* MSDOS compatibility mode FPU exception support */ -void cpu_set_ferr(CPUX86State *s); +void x86_register_ferr_irq(qemu_irq irq); +void cpu_clear_ferr(void); /* mpx_helper.c */ void cpu_sync_bndcs_hflags(CPUX86State *env); =20 diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 005f1f6..4db0059 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -26,6 +26,10 @@ #include "exec/cpu_ldst.h" #include "fpu/softfloat.h" =20 +#ifdef CONFIG_SOFTMMU +#include "hw/irq.h" +#endif + #define FPU_RC_MASK 0xc00 #define FPU_RC_NEAR 0x000 #define FPU_RC_DOWN 0x400 @@ -58,6 +62,26 @@ #define floatx80_l2e make_floatx80(0x3fff, 0xb8aa3b295c17f0bcLL) #define floatx80_l2t make_floatx80(0x4000, 0xd49a784bcd1b8afeLL) =20 +#if !defined(CONFIG_USER_ONLY) +static qemu_irq ferr_irq; + +void x86_register_ferr_irq(qemu_irq irq) +{ + ferr_irq =3D irq; +} + +void cpu_clear_ferr(void) +{ + qemu_irq_lower(ferr_irq); +} + +static void cpu_set_ferr(void) +{ + qemu_irq_raise(ferr_irq); +} +#endif + + static inline void fpush(CPUX86State *env) { env->fpstt =3D (env->fpstt - 1) & 7; @@ -137,7 +161,7 @@ static void fpu_raise_exception(CPUX86State *env, uintp= tr_t retaddr) } #if !defined(CONFIG_USER_ONLY) else { - cpu_set_ferr(env); + cpu_set_ferr(); } #endif } --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571931801; cv=none; d=zoho.com; s=zohoarc; b=Wh/x+MmqpVYd67sNTuOFh+vCDfPCXaF8CYvFI25jZFdXgx+VDko6dE5a96x0ZpTD1+Zp1G7B/cwCgXwvEzrvPZURrhi1jYrsvWx1cJ3nk4Z9ZnTt7LHcmVsrlXMu8lF7G+wqsEoI2qPp3c5MmWdoSX09FqDoPnK1ETXRJOt2/RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931801; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ACSSwd4vLiPduucfk8qILiYK3BU6NBbxPynhmSEzC6A=; b=fMAXco6V+QhVf2UUyMRt1un+9uriNCzGMEd6T+9Lre90kWiQcy92f2mr50bZB8BgDkdIqc8YClQBZA05thue/SRUddlKsxOwP1+2UuGI2RjUS3RLPmicfbZL9BI+4WAD/frlfQUduPFGWbNyKG72o7r5US8yIj7YnLNDbj7DpFw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571931801811498.67670481816947; Thu, 24 Oct 2019 08:43:21 -0700 (PDT) Received: from localhost ([::1]:45552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfGi-0000z1-HL for importer@patchew.org; Thu, 24 Oct 2019 11:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35030) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjF-0008LG-L8 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjE-0007xB-7I for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:41 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjE-0007we-17 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:40 -0400 Received: by mail-wr1-x442.google.com with SMTP id s1so17473487wro.0 for ; Thu, 24 Oct 2019 07:04:39 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=ACSSwd4vLiPduucfk8qILiYK3BU6NBbxPynhmSEzC6A=; b=YXoEhScKkoeIwTfYdNx/Gv6m/u6kNPKPze0mWwwCVCV3hmU7UNVgefmnmw41th7Rp+ mZjC7jet6BAgq6QFHKGuYGQVcB/k8CuoRx+Z0xpdESTe4sIiXz3sCkTSA+5psfnEZbZT hnBR5fvkkHuqQzFT70VHLeIBfct0yKoOq/pzdJp6aHdnWGVsERR+PNkZHVZDLWRiyQ4v oMCZ4SS6QJzexh3bwll0nFREhKrIrXTFZQGLwdfP3c+jMQvUsCsUMALv+uyNXK1FXN1q 0p8hD3evedbLYF6yJo17raNzCpMdV/TzW8RfQ/281Fbt/DniAOC8+1HbSWMafNbYPb0m 9a5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=ACSSwd4vLiPduucfk8qILiYK3BU6NBbxPynhmSEzC6A=; b=lNhj03OERNVT/G+tZ6hli91wl2gRu7lBr5pdQOOFQIzW26Jdf0S6iyWsA1dPBw2JzH A3p3SDqQW6zBrk3uaRVFtSShW+FReHh3jksWxv5gNidV3YP8ZEgTDSOHMmMxOPaoXAqU jqRRLszm8k3vbdbtUesPMR0Jbhzu0oI3WFBmNpHZjXy9IsSR3mwscj4GJXlLurEqX9MC vuN/HfQyVo4CEyAtIcedMp7guXbOdUUjGTmFWWIwIn3yBbohx/I9XXP5eLRTPJ41xfWH 9V+p/vIPGpztTDLJOoJ0WhCczcHWaI25ywDL9YRhFPPhrdGU695gE+5+EMek61/yq8Bv ySYw== X-Gm-Message-State: APjAAAVZ6Wuv67X3YHayvVjpSz77yK57yvyCHcSCKXrqc2pvKe2llt4r ZIqTnBgSfnu2R+QEte4+WYKLhlWh X-Google-Smtp-Source: APXvYqxQDSGFdpPuxTzYN3MHJYdSlYSzwda4d+Kf9uxWHaQVOqAYtpeAGeGCSf89acBPCLRhsIRDXQ== X-Received: by 2002:adf:a48c:: with SMTP id g12mr3830271wrb.212.1571925878701; Thu, 24 Oct 2019 07:04:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 38/39] target/i386: introduce cpu_set_fpus Date: Thu, 24 Oct 2019 16:03:54 +0200 Message-Id: <1571925835-31930-39-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the next patch, this will provide a hook to detect clearing of FSW.ES. Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 4db0059..6825024 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -1053,6 +1053,12 @@ void helper_fstenv(CPUX86State *env, target_ulong pt= r, int data32) do_fstenv(env, ptr, data32, GETPC()); } =20 +static void cpu_set_fpus(CPUX86State *env, uint16_t fpus) +{ + env->fpstt =3D (fpus >> 11) & 7; + env->fpus =3D fpus & ~0x3800; +} + static void do_fldenv(CPUX86State *env, target_ulong ptr, int data32, uintptr_t retaddr) { @@ -1067,8 +1073,7 @@ static void do_fldenv(CPUX86State *env, target_ulong = ptr, int data32, fpus =3D cpu_lduw_data_ra(env, ptr + 2, retaddr); fptag =3D cpu_lduw_data_ra(env, ptr + 4, retaddr); } - env->fpstt =3D (fpus >> 11) & 7; - env->fpus =3D fpus & ~0x3800; + cpu_set_fpus(env, fpus); for (i =3D 0; i < 8; i++) { env->fptags[i] =3D ((fptag & 3) =3D=3D 3); fptag >>=3D 2; @@ -1316,8 +1321,7 @@ static void do_xrstor_fpu(CPUX86State *env, target_ul= ong ptr, uintptr_t ra) fpus =3D cpu_lduw_data_ra(env, ptr + XO(legacy.fsw), ra); fptag =3D cpu_lduw_data_ra(env, ptr + XO(legacy.ftw), ra); cpu_set_fpuc(env, fpuc); - env->fpstt =3D (fpus >> 11) & 7; - env->fpus =3D fpus & ~0x3800; + cpu_set_fpus(env, fpus); fptag ^=3D 0xff; for (i =3D 0; i < 8; i++) { env->fptags[i] =3D ((fptag >> i) & 1); --=20 1.8.3.1 From nobody Fri May 3 23:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571932027; cv=none; d=zoho.com; s=zohoarc; b=UVs5II8fOUKVuq5r3Hrjgr8RC58/TTRpQuxU/sI4ZVQPdzsRZbq70xMsIZVvCEon4WSvcgfO4QqP2rVNQxnP53KPAKLdeu5hyGBU1sa+Xi+/JxU/iqFJ40fdNNULDLYYsDjiJE5smqy7Ati70FpHl2SfPEZlZ9BAVsODh38MzR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571932027; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hs3ekp8CnLHyDVgFbGkCYGX2UG3bGpyZUnsgM/bA+io=; b=gPGlG8Ue6jyUTuJhVUdavZ3HO0+l1MO86YxLgCF6qNjT1sgb8XjVE4o9rSJ3kBaBmudD5QdmydW9FxQgcMc6hdY5hc9ouZfPn1lRh78CIkeW4kfJfDS0ynQVJkKCM+vjUp27ueFukiheQ6BxxasLMOSRGLZYYllyTGwHX5Bsk1g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571932027014208.9846642536038; Thu, 24 Oct 2019 08:47:07 -0700 (PDT) Received: from localhost ([::1]:45604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfKL-0002DT-IA for importer@patchew.org; Thu, 24 Oct 2019 11:47:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdjG-0008O6-Pe for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdjF-0007y5-AH for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:42 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51397) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdjF-0007xO-3i for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:41 -0400 Received: by mail-wm1-x341.google.com with SMTP id q70so3013197wme.1 for ; Thu, 24 Oct 2019 07:04:41 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=hs3ekp8CnLHyDVgFbGkCYGX2UG3bGpyZUnsgM/bA+io=; b=r7Fj5dEzBAZJ61VvjvvXtAO8/av+7byDTbxOIH7LMC92gqndUfZNA4YseXUqCNu4rs z2epSrmxWUIzvn/OOcas2gF8PsgWtt1EbxdSyl/oQ0u1YgG4btZm6m9TpaSDCM1oF7bT wgqI3SqFs/mShN9Kpif7m1jfXrH7OnYbB0hvLyLStFInroJ+tEakRWAlFd9gQYdSVG4j aaJnNVxQpKAlNo30rCJN1cF39gd5qSMY5F9LHWGuNMi0jiFpxw2N70RbS51OlDt0slWS iIk+PXsvfIeGU3jTy5uwnDI3pySyQWGv5K2wIHfH9KHxucR9r4CpeXOCSWI/rp0tyvqB p81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=hs3ekp8CnLHyDVgFbGkCYGX2UG3bGpyZUnsgM/bA+io=; b=er070TLY5z8+FN1f0Usty4U7MHDyr0w5jqAfqvigfYJcOFA3mMJV/6qnvTXQmOZEka Ort3gzyHWyIKdK6Oyy6X/+GITbDrq/CgBXpGkZeszHK+Ej85/Ffy1vKubqYyDs/ZEIrz +JBx6150Eg60Ab7hQf5W9xabg6NIDMfFH6AYWh9Jv99BaBMgl03MdcRnA0HlBsH6Kmds VuI4eQuq+B10tgftt4M6I4riZB0TJdzbUmXwYBePmSoQutZ3O2tEJCrKWpi7cXArOTiw cxCgzTnYbd7bNZzr8iY2pDwydJFMdxLwEu5Vjh2qCMotscOSM7q8hk9WQEWEPqS5D7uC dnag== X-Gm-Message-State: APjAAAUn/5IxtvifgMCY+nzP0siwrC2AOEDOBsoB13frr7FkkpjS2DFo WxW0OLVy4Ej6C/NmxYteh2pspCsR X-Google-Smtp-Source: APXvYqypAw00Z5CzoK4GZv2D1OoMhxL8/qr0aBKvaXE2h0t7o8np5MIRFgROQ2a07kLFSMOa8WHiJA== X-Received: by 2002:a1c:398b:: with SMTP id g133mr5415568wma.130.1571925879801; Thu, 24 Oct 2019 07:04:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 39/39] i386: implement IGNNE Date: Thu, 24 Oct 2019 16:03:55 +0200 Message-Id: <1571925835-31930-40-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Change the handling of port F0h writes and FPU exceptions to implement IGNN= E. The implementation mixes a bit what the chipset and processor do in real hardware, but the effect is the same as what happens with actual FERR# and IGNNE# pins: writing to port F0h asserts IGNNE# in addition to lowering FP_IRQ; while clearing the SE bit in the FPU status word deasserts IGNNE#. Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 2 +- target/i386/cpu.h | 4 +++- target/i386/fpu_helper.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 66d865b..174b0bd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -385,7 +385,7 @@ static void ioportF0_write(void *opaque, hwaddr addr, u= int64_t data, unsigned size) { if (tcg_enabled()) { - cpu_clear_ferr(); + cpu_set_ignne(); } } =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 01e052b..5352c9f 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -203,6 +203,7 @@ typedef enum X86Seg { #define HF2_SMM_INSIDE_NMI_SHIFT 4 /* CPU serving SMI nested inside NMI */ #define HF2_MPX_PR_SHIFT 5 /* BNDCFGx.BNDPRESERVE */ #define HF2_NPT_SHIFT 6 /* Nested Paging enabled */ +#define HF2_IGNNE_SHIFT 7 /* Ignore CR0.NE=3D0 */ =20 #define HF2_GIF_MASK (1 << HF2_GIF_SHIFT) #define HF2_HIF_MASK (1 << HF2_HIF_SHIFT) @@ -211,6 +212,7 @@ typedef enum X86Seg { #define HF2_SMM_INSIDE_NMI_MASK (1 << HF2_SMM_INSIDE_NMI_SHIFT) #define HF2_MPX_PR_MASK (1 << HF2_MPX_PR_SHIFT) #define HF2_NPT_MASK (1 << HF2_NPT_SHIFT) +#define HF2_IGNNE_MASK (1 << HF2_IGNNE_SHIFT) =20 #define CR0_PE_SHIFT 0 #define CR0_MP_SHIFT 1 @@ -1762,7 +1764,7 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env); int cpu_get_pic_interrupt(CPUX86State *s); /* MSDOS compatibility mode FPU exception support */ void x86_register_ferr_irq(qemu_irq irq); -void cpu_clear_ferr(void); +void cpu_set_ignne(void); /* mpx_helper.c */ void cpu_sync_bndcs_hflags(CPUX86State *env); =20 diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 6825024..99f28f2 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -70,14 +70,24 @@ void x86_register_ferr_irq(qemu_irq irq) ferr_irq =3D irq; } =20 -void cpu_clear_ferr(void) +static void cpu_clear_ignne(void) { - qemu_irq_lower(ferr_irq); + CPUX86State *env =3D &X86_CPU(first_cpu)->env; + env->hflags2 &=3D ~HF2_IGNNE_MASK; } =20 -static void cpu_set_ferr(void) +void cpu_set_ignne(void) { - qemu_irq_raise(ferr_irq); + CPUX86State *env =3D &X86_CPU(first_cpu)->env; + env->hflags2 |=3D HF2_IGNNE_MASK; + /* + * We get here in response to a write to port F0h. The chipset should + * deassert FP_IRQ and FERR# instead should stay signaled until FPSW_S= E is + * cleared, because FERR# and FP_IRQ are two separate pins on real + * hardware. However, we don't model FERR# as a qemu_irq, so we just + * do directly what the chipset would do, i.e. deassert FP_IRQ. + */ + qemu_irq_lower(ferr_irq); } #endif =20 @@ -160,8 +170,8 @@ static void fpu_raise_exception(CPUX86State *env, uintp= tr_t retaddr) raise_exception_ra(env, EXCP10_COPR, retaddr); } #if !defined(CONFIG_USER_ONLY) - else { - cpu_set_ferr(); + else if (ferr_irq && !(env->hflags2 & HF2_IGNNE_MASK)) { + qemu_irq_raise(ferr_irq); } #endif } @@ -1056,7 +1066,17 @@ void helper_fstenv(CPUX86State *env, target_ulong pt= r, int data32) static void cpu_set_fpus(CPUX86State *env, uint16_t fpus) { env->fpstt =3D (fpus >> 11) & 7; - env->fpus =3D fpus & ~0x3800; + env->fpus =3D fpus & ~0x3800 & ~FPUS_B; + env->fpus |=3D env->fpus & FPUS_SE ? FPUS_B : 0; +#if !defined(CONFIG_USER_ONLY) + if (!(env->fpus & FPUS_SE)) { + /* + * Here the processor deasserts FERR#; in response, the chipset de= asserts + * IGNNE#. + */ + cpu_clear_ignne(); + } +#endif } =20 static void do_fldenv(CPUX86State *env, target_ulong ptr, int data32, --=20 1.8.3.1