From patchwork Mon Sep 16 14:41:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IvaP5gIB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9Mc3GDWz9sPq for ; Tue, 17 Sep 2019 01:36:44 +1000 (AEST) Received: from localhost ([::1]:35966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t3R-0000rg-N6 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:36:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53543) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCl-0006FP-4T for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCj-0007Ov-Lb for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:14 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:33082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCj-0007OY-Bi for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:13 -0400 Received: by mail-wr1-x431.google.com with SMTP id b9so5595624wrs.0 for ; Mon, 16 Sep 2019 07:42: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=YKW2Y+e7G2qkXzUR5XTC1dqXN0+JuqZwNXAZTTRmCi4=; b=IvaP5gIBmrC/4DUFcqOpdwesGChREks7RykTzhC9l+jNXTo4CmivPXNAR+UfQDGEx0 QCAF7TAUaThkU/UFYsvCOJy7tmYJVxcb57iKFHiPeeupuXXRlauRS0g31LtqchHtCr5n znLuCZavB6zMklIe3ZCyFruG5MNTk4awBdF/KdIHssuwW42pA8tqMA1JtpZkx6uhdq9I ncKm5hiZ/5etsySPigPNxpBtPpdF17CZfIVycCKAkOMIQGekTHXTdIWDFVIzFG9mKTfd +PjApwLG/gmhzz3mtqrJZwWu0oudh7Z8cDP/cueONnWpEEy5Sq8bEEUJGJ7GYcXY3nDN NZVA== 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=YKW2Y+e7G2qkXzUR5XTC1dqXN0+JuqZwNXAZTTRmCi4=; b=GDa11oNTooSQQqTh5+nNvlcraWzhLhwoT1tXHh5RyYKuEQfrnfLZDdUoTWS0GIDZuG sjIjW+Tk6VQyQW2nDurg87cPWQOtxstUbjYwv/+Ll8pfsvVaV4eVaW1XgVaZiivaa4Pq a3jakFuC76YMzuyCA664hP6c14SpYtbdPJU1ro66xz4i17PvE2RIfki2NRfE1keOSMco YNm7ISyHfTgCFEZwMAvWeTpvVuIRL7HCU3HRzcepMwL3/ER2VBtft+ik/PqugkCAmCJg c6//q58KaQ19qcMAFTA82pxiqvhIkaoafZpZfJVK1z2ISQaJVlLVj8b/qpoiD80gt6zN E8zA== X-Gm-Message-State: APjAAAVPRgrMsm6TKMAmxNUtiMW5f5UAjqS3BEM3Gn687F10T2PnJWZn VMi4G9O3dAOh2gi0cPwQo8KZeb/P X-Google-Smtp-Source: APXvYqxLViKlkJ/7umDpDDZxbvo9fHqk33ZdOSOfARXpU4JgZaygykS70v50qIbZbrp30ogf+dkZyQ== X-Received: by 2002:a5d:694e:: with SMTP id r14mr152206wrw.34.1568644931756; Mon, 16 Sep 2019 07:42:11 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:41 +0200 Message-Id: <1568644929-9124-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 01/29] i386/kvm: support guest access CORE cstate 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: Wanpeng Li , Eduardo Habkost , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wanpeng Li Allow guest reads CORE cstate when exposing host CPU power management capabilities to the guest. PKG cstate is restricted to avoid a guest to get the whole package information in multi-tenant scenario. Cc: Eduardo Habkost Cc: Paolo Bonzini Cc: Radim Krčmář Signed-off-by: Wanpeng Li Message-Id: <1563154124-18579-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini --- linux-headers/linux/kvm.h | 4 +++- target/i386/kvm.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index c8423e7..18892d6 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -696,9 +696,11 @@ struct kvm_ioeventfd { #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +#define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ KVM_X86_DISABLE_EXITS_HLT | \ - KVM_X86_DISABLE_EXITS_PAUSE) + KVM_X86_DISABLE_EXITS_PAUSE | \ + KVM_X86_DISABLE_EXITS_CSTATE) /* for KVM_ENABLE_CAP */ struct kvm_enable_cap { diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 8023c67..3435fc4 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2076,7 +2076,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) if (disable_exits) { disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | KVM_X86_DISABLE_EXITS_HLT | - KVM_X86_DISABLE_EXITS_PAUSE); + KVM_X86_DISABLE_EXITS_PAUSE | + KVM_X86_DISABLE_EXITS_CSTATE); } ret = kvm_vm_enable_cap(s, KVM_CAP_X86_DISABLE_EXITS, 0, From patchwork Mon Sep 16 14:41:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162904 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UqqP7Y2K"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8Xk1wBjz9sQm for ; Tue, 17 Sep 2019 00:59:34 +1000 (AEST) Received: from localhost ([::1]:35582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sTU-0006Pf-0U for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 10:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53560) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCl-0006GR-UG for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCk-0007PG-D0 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:15 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:53569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCk-0007Oi-5e for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:14 -0400 Received: by mail-wm1-x335.google.com with SMTP id i16so66444wmd.3 for ; Mon, 16 Sep 2019 07:42: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; bh=BH5zjCOPtAcwRwF/m1vkOuO1t45pMW2sTYdJyy0lbOE=; b=UqqP7Y2KphmLVWZ68/JQagmEJxYPp8k5fZQG1sZzXLc9Clnq+orm67ReBhXlq8Ikg/ Kwn/hXUNMtkLXoq6dUtCCIFsAN/jbJ7g0FO8laCR8QAhDotkgOKsIvEd2JJY6yp6YYr3 pq1mGCln9rdlv+ewZ78ZrmAQJ7P7KXptOzyRgYsj6rOTNBeOL0+qcVWgNlmt1PikO2qE zyjmEm72KhMHWxDFRMIVVDOskQ7lZx9xqyVHlTTQQSTonhDCOx+SDhbK7UJVKBjjIVY8 oiHS+Is0pGPVs65QL1IkEn+ZuIo8bHEGqQRRgKDz0vJDJJ6TDJSppJG4tkeOKdZ6pyZf T3Gw== 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=BH5zjCOPtAcwRwF/m1vkOuO1t45pMW2sTYdJyy0lbOE=; b=HD4AnwbdN2sBV35aQlIiImm3bCxa77M/Rtm2tZ/2bNgisyyT+RBUYcFCJ6GHbw55pc kLi0LjYTSRSWCoj+0/WlJs4MwrP6600ACMqqPMo6QgDWHUFQs/tVvXI9OwXejj6gQPMI OLa2uVHBSwAVqkhfNNw66Z2fuv4V8gS9z+32mWd6fhu8FyVzQybOvouA1xR9a/ymktOE 9vhzbUxKce/AHJR4fRdlmIGw/ovkeCntwRv7XJg7pdGDzqWE6ntazUJbNxviLFtdRqKN Ii7Q/T1/fvgMAq47OUS7l68sO6m83XRAzedgyPTFzJELEMkOZfu2igYbYsaQtbI6kSkl 0P/g== X-Gm-Message-State: APjAAAX1zFcd13MHZyBKj3fQ59aKVTKpOnHuZ1uelHyp6qSCYzkChGEg CgjLb5AwPIXru3cSByuM615bASg/ X-Google-Smtp-Source: APXvYqxTKQNw+1a8VwcnTWccU78ZRFUAOeaoYc/8Lo45cafMBndCJz0P3IC6hbpemJty8cakzb53vg== X-Received: by 2002:a7b:c182:: with SMTP id y2mr50394wmi.156.1568644932764; Mon, 16 Sep 2019 07:42:12 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:42 +0200 Message-Id: <1568644929-9124-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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 Subject: [Qemu-devel] [PULL 02/29] exec.c: replace hwaddr with uint64_t for better understanding 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang Function phys_page_set() and phys_page_set_level() 's argument *nb* stands for number of pages to set instead of hardware address. This would be more proper to use uint64_t instead of hwaddr for its type. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-2-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 235d6bc..8e0c400 100644 --- a/exec.c +++ b/exec.c @@ -255,7 +255,7 @@ static uint32_t phys_map_node_alloc(PhysPageMap *map, bool leaf) } static void phys_page_set_level(PhysPageMap *map, PhysPageEntry *lp, - hwaddr *index, hwaddr *nb, uint16_t leaf, + hwaddr *index, uint64_t *nb, uint16_t leaf, int level) { PhysPageEntry *p; @@ -281,7 +281,7 @@ static void phys_page_set_level(PhysPageMap *map, PhysPageEntry *lp, } static void phys_page_set(AddressSpaceDispatch *d, - hwaddr index, hwaddr nb, + hwaddr index, uint64_t nb, uint16_t leaf) { /* Wildly overreserve - it doesn't matter much. */ From patchwork Mon Sep 16 14:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Uy5I00Yo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8dc5B4yz9sPw for ; Tue, 17 Sep 2019 01:03:47 +1000 (AEST) Received: from localhost ([::1]:35642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sXX-0001RR-OS for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:03:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53581) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCn-0006I7-4U for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCl-0007Pm-HG for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:16 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:53560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCl-0007PL-88 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:15 -0400 Received: by mail-wm1-x32b.google.com with SMTP id i16so66533wmd.3 for ; Mon, 16 Sep 2019 07:42: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=qBDro2giL3yKmpBcWouyjZdZj6DkaNRvbVZ4F52Urqc=; b=Uy5I00YoR6QZNcCHg0GO34eEQ+dOyeSalui4EIjgMxdRmdddh04KsDEEkQZlQDoI7w vLoLFaeEP18J7NasZmlP3AlqC3dflywVwigjSQ4ZmCbS6MJc70WmzeuhxGjh8e9uFcrD GzisGljFz0zDRh4e/HRGsCSbo2nmCbSJsxiWOPt9DKFJlreTMMSOEkJC1JxkK92geLQs umKlRMaGeRGXZMxBuWVmpwKRZ0nHFcqiCA7Cd9Ac6ZKh604A+xhtP7EtjqkJOpKWS0oP dxhTzMwSXzMVBNo8/co7cczlUaOpej2LVC0KjXWgnLcV8da+GcMsVtDkg/V+anmTT+RF 4AuA== 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=qBDro2giL3yKmpBcWouyjZdZj6DkaNRvbVZ4F52Urqc=; b=EieQo6Il/8ouvEF4IqpxTAmtJXSOOOt9hm5/peQYlGR2aQ0aGpwWYjUJMRse7JdoNw NbFGH8wpHoazypMeUvqwTUW6i9h7sf5RTAx1Y/BWfHabmIs7oRgrA/G0LuOV2AEk6SUs edi8uupd2WMoZDlyyplERmNvAl6Wm2EglA8OH6OZ5nYFXMgUFg4kPNLcnvGdran0w2Ho 69kbeFIDfibDtrw6DvTiTYrjNObug0G/GVCzeVMkvz2cNl5Ecn4AH8q9RtPc1zehA8jo ggIt85ery3jbZ2/qhKWcqxFij5fAhRlo9eJfAYpNQ/IJuUFnFcMrnLIEqvDNqDazddbY Sk2A== X-Gm-Message-State: APjAAAVKRU6Yb5oEFyZOQ1RW9q69Nj4Sb/TI/k9a5tw7Reb0nIKsr/CE EUog5gxTsDkKOqELv0MhlnePJgOx X-Google-Smtp-Source: APXvYqx3hlHbaEFZIviI00ch2wJLL+lmkTjtGW94KJT3ngqB/w2rjLuBleOS8iDjQN8/SWMGY7E3sw== X-Received: by 2002:a7b:c391:: with SMTP id s17mr66082wmj.94.1568644933985; Mon, 16 Sep 2019 07:42:13 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:43 +0200 Message-Id: <1568644929-9124-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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 Subject: [Qemu-devel] [PULL 03/29] exec.c: get nodes_nb_alloc with one MAX calculation 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang The purpose of these two MAX here is to get the maximum of these three variables: A: map->nodes_nb + nodes B: map->nodes_nb_alloc C: alloc_hint We can write it like MAX(A, B, C). Since the if condition says A > B, this means MAX(A, B, C) = MAX(A, C). This patch just simplify the calculation a bit. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-4-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 8e0c400..ff3cb3e 100644 --- a/exec.c +++ b/exec.c @@ -227,8 +227,7 @@ static void phys_map_node_reserve(PhysPageMap *map, unsigned nodes) { static unsigned alloc_hint = 16; if (map->nodes_nb + nodes > map->nodes_nb_alloc) { - map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, alloc_hint); - map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, map->nodes_nb + nodes); + map->nodes_nb_alloc = MAX(alloc_hint, map->nodes_nb + nodes); map->nodes = g_renew(Node, map->nodes, map->nodes_nb_alloc); alloc_hint = map->nodes_nb_alloc; } From patchwork Mon Sep 16 14:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="duaHcljH"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8jH3pyMz9sRH for ; Tue, 17 Sep 2019 01:06:59 +1000 (AEST) Received: from localhost ([::1]:35688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sae-0005L0-Md for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCo-0006Jb-Fk for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCm-0007Q5-Df for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:18 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:52184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCm-0007Ph-17 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:16 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 7so80693wme.1 for ; Mon, 16 Sep 2019 07:42: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=mE/BuqEE8gv/JobfMAiia0z3Ltz3qiUZMeH9v73HiNI=; b=duaHcljHBMDeBPj8+dxOx69c5+tMT1BrLsxK18JJKUDoeLkIACjQzFnNM30SlCvHuQ BS/lex4pHFOJi+OPj8QHNxyni8UOCKMghX/hDSXog90hAylo7uzJW17OKpst5Bw7iDHS hZnBQVWbQSP7c+wNXKmdGNoySGRDH1sjiYfC49mmB5ZRVFRqFHGuCo2h/mXuTWIMYOYA WEzhHDqIGXYch1JN3MHMLWJ7UTWNNUS2n+dNiEPO7nBeHLD6Ye8JZbRIy0ylJigJHkS3 UHPIPWzjDOgong05a60znkUlVCWKHNsVoEod5pUtqa9wrrlteZqJmlj/7vIAqpkhj8VQ 0hHw== 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=mE/BuqEE8gv/JobfMAiia0z3Ltz3qiUZMeH9v73HiNI=; b=tObuyt3yjlrfOSm/a7BbckssOlzXkm3PyrP6uHdVyVNSVPT8SP8dhCAnVenqiS/Afv M6ZR4zs9iLNSD7v9beB4YLCNs/ZzD3D73FGLForhJoC6D+AwnuiqK+rJXQhjestvYMnU M/qFnbGN+JQw4tL2L7psE/6eIQ8Gtnfn144d9H+s6+OPVcDBnrQqLwF/kOCvXUSkjR5o /Nex/1xeDGWwI+7P9LaClGbvLaWtCC2FrgfUoPfTtQ+/Oq4FAKgkhlwvCnxarlCJWnsM JSttt7KGCQtcm2ZKm0SodkMxeu++NCnBohZwXN5ZzNEdd0WnVviprc5Ki0R8H4Jp8gBq G5dw== X-Gm-Message-State: APjAAAX/BOv7Stm6xDtRVY6fslmUmsNyz/yrA06b3PlOTdg/MrTpqfFl jMSvDXQADVMZs91SzkEBTvQg7i8x X-Google-Smtp-Source: APXvYqyZNgif8Elheu7kUKrwItLHC7HqeMIbhaqH2FZTgsimIA2VrI7LugzlDBgBdDnvBdA5Hca5Rw== X-Received: by 2002:a1c:a404:: with SMTP id n4mr37094wme.41.1568644934721; Mon, 16 Sep 2019 07:42:14 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:44 +0200 Message-Id: <1568644929-9124-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::32f Subject: [Qemu-devel] [PULL 04/29] exec.c: subpage->sub_section is already initialized to 0 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang In subpage_init(), we will set subpage->sub_section to PHYS_SECTION_UNASSIGNED by subpage_register. Since PHYS_SECTION_UNASSIGNED is defined to be 0, and we allocate subpage with g_malloc0, this means subpage->sub_section is already initialized to 0. This patch removes the redundant setup for a new subpage and also fix the code style. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-5-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exec.c b/exec.c index ff3cb3e..d9827ef 100644 --- a/exec.c +++ b/exec.c @@ -1491,8 +1491,8 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, #if !defined(CONFIG_USER_ONLY) -static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, - uint16_t section); +static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, + uint16_t section); static subpage_t *subpage_init(FlatView *fv, hwaddr base); static void *(*phys_mem_alloc)(size_t size, uint64_t *align, bool shared) = @@ -2913,8 +2913,8 @@ static const MemoryRegionOps subpage_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, - uint16_t section) +static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, + uint16_t section) { int idx, eidx; @@ -2937,6 +2937,7 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr base) { subpage_t *mmio; + /* mmio->sub_section is set to PHYS_SECTION_UNASSIGNED with g_malloc0 */ mmio = g_malloc0(sizeof(subpage_t) + TARGET_PAGE_SIZE * sizeof(uint16_t)); mmio->fv = fv; mmio->base = base; @@ -2947,7 +2948,6 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr base) printf("%s: %p base " TARGET_FMT_plx " len %08x\n", __func__, mmio, base, TARGET_PAGE_SIZE); #endif - subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, PHYS_SECTION_UNASSIGNED); return mmio; } From patchwork Mon Sep 16 14:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B8Rm226j"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8gq2gQHz9sR8 for ; Tue, 17 Sep 2019 01:05:43 +1000 (AEST) Received: from localhost ([::1]:35676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sZQ-0003vu-8W for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:05:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53607) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCp-0006KT-5T for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCn-0007Qi-Eb for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:18 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCn-0007Q1-32 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:17 -0400 Received: by mail-wr1-x432.google.com with SMTP id v8so3819656wrt.2 for ; Mon, 16 Sep 2019 07:42: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=XFqUfZ0D+qjTEWF2tGgFMQF/kgJJHpcKbhrb9txVbKA=; b=B8Rm226j0iatczokUjljTF5QA7+6reh4Bx5DkXsExrYpF9oK3HeQuAjI58sNUv1vaz fn+7IL35uEiH+RB6lifq21t2vKQWWMgNcUrTzrWhWScFoaZNse2SiRf93x+GzXOWE43z Z8BqQsz2Uwc5V5R+ssrlifdNnIhpcwq75hCWY9sI/FUpYc3ErICj5HAmlrSPC7XOltcu vwnwAa7n20JMlon9rDvQ/QmYwQ+2nAcrNRK3pwGF3osYuGh7rF0a+m5ivvt7a7MI4VTT hVpYLWkcPz8I2+HXIm5HbnYDMeCps1Q0xRmuQFFkuAZ8OVewwU7BRMi9TlomlyHfNEEN iIng== 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=XFqUfZ0D+qjTEWF2tGgFMQF/kgJJHpcKbhrb9txVbKA=; b=qxXdi9JT/St/DcWFI83Lmfv2yURRJuewtRJMJtr6GOtXtt0UwOTF1zBsutgNtrFI4U 1pNCYjyztF3V6IdPpvo6dXaZk+2Cd8dChcyLpYgRf0QEq7CYHfYO/m+fwkEGPzXTZK6V HRcPPiOve0ISP6Ysd/WLJc5r0z7w+G/KPptq11GSnf0L3+Zk4tye2Kdl7HMn6QRSzx0r 4xPclFkUjK1i264gtOyV+NInEWtmKt9F5GDhEvpm0rdW31AxWyb0FHoIKp/SBIgzUOXm OFWsy8lRmLsHNmyl7dbMJ1kNsTg5gCcmO4zQBLjXiARAE14A0tg3VALSQxl7APfMtXNK 8h0A== X-Gm-Message-State: APjAAAUszM2o7pOvwLK8N6xftubYlJkY/Q34Kk7J7fbqKnOemPprh21S gneQ1Fw5WBbJx2b6N8LdlpRang1/ X-Google-Smtp-Source: APXvYqxSL+q0ZO7Cx8+j3Je9PXyS769us4xiWkAjSLq0/+OeRK4ZLWvyymLeYYvHuI0p2R2TOoxpXA== X-Received: by 2002:adf:d848:: with SMTP id k8mr112778wrl.254.1568644935671; Mon, 16 Sep 2019 07:42:15 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:45 +0200 Message-Id: <1568644929-9124-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::432 Subject: [Qemu-devel] [PULL 05/29] exec.c: correct the maximum skip value during compact 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang skip is defined with 6 bits. So the maximum value should be (1 << 6). Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-6-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index d9827ef..d1969bb 100644 --- a/exec.c +++ b/exec.c @@ -324,7 +324,7 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes) assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >= (1 << 3)) { + if (lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; } From patchwork Mon Sep 16 14:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gGctzBmD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9KS1sk0z9sPq for ; Tue, 17 Sep 2019 01:34:52 +1000 (AEST) Received: from localhost ([::1]:35956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t1d-0007Dk-Hv for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:34:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53617) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCq-0006Lr-9g for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCo-0007Qy-77 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:19 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:39492) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCn-0007QZ-RL for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:18 -0400 Received: by mail-wm1-x32a.google.com with SMTP id v17so67965wml.4 for ; Mon, 16 Sep 2019 07:42: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; bh=+yIB4TtQhEbL/mvyJX2uAbbwQXERvRXJT6x1cyUEp28=; b=gGctzBmDa0dX/K+PN9zIT/2Cyfz2c9jVUZVsmnAzkqtqU96ioIRFWLTFWtaf/FY4kQ 0WvygNVjnhczvv1DUdL6ZqTXRKQ+9P+MZBIXnRnSR/Jo7isP/DN4f636YPhzpe3L3QlL bEjSt9Uaguc5XxAkk43E5ynmqKhJp5dR5rax0p4M7o94AhOGwb0ra/61LR8+ibkRu+hT 12D+ef7UJR4j+NpryoB7zstLsZoLvoJ16DBHEFiqbTAHaii2IfsFHT3vcoqjwY015Vrh DZbRU5VOPxi8HEgQqqpX5dyZHezY9Q0Fsj2Cp25Is9ce2nbgC9s0epEqwBAquLdREGUV MhAg== 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=+yIB4TtQhEbL/mvyJX2uAbbwQXERvRXJT6x1cyUEp28=; b=Cx4mPAXnTGxQDaN337jeLXdy+4QUMh1chX4G+irelX0ac9PrmGmAYo5q5ZeDIa50u6 +KBmUTZ7dpCyoQjn+LQ1yZdIsV7U8DoNm20FYUYDicjBl1xAJNsu5lhL4FFjTgMYLJJT le4OMVs+h3IZBZTlTozMXQVDP04t0YhGcmgUDx/BrRhLaCaa9d0IGaohCnH/55LzVOhY Ba0c+jjSGyo8l4JuGMQw9+Ek/RXR5vaWB3BJpOUu+3ZQweua2WvOA8+VywTY55kndnJ/ r8R/hkmKa06QzLAqJ4Az8btrjwgL3LllQn0VPluF519iBbizvNv0a3tYY5ZLl+NbWnFd 2xlg== X-Gm-Message-State: APjAAAX3Q4QfOi+OsFMyYIAcmxvenwAEp40++0tASP5H6Zil+j5Qe0tA 9K2pFHgINWTakjbREvPzvA+84OvJ X-Google-Smtp-Source: APXvYqyDz/3AbEWbzAvt5nwmmzrcx1dfFYP7ZrtH4DDSQOfQc+zLzwiIyxktchUcllZc4PKbOiwxWw== X-Received: by 2002:a05:600c:28d:: with SMTP id 13mr64703wmk.84.1568644936605; Mon, 16 Sep 2019 07:42:16 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:46 +0200 Message-Id: <1568644929-9124-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::32a Subject: [Qemu-devel] [PULL 06/29] exec.c: add a check between constants to see whether we could skip 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang The maximum level is defined as P_L2_LEVELS and skip is defined with 6 bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the boundary. Since this check is between two constants, which leverages compiler to optimize the code based on different configuration. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-7-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index d1969bb..b9511be 100644 --- a/exec.c +++ b/exec.c @@ -324,7 +324,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes) assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >= (1 << 6)) { + if (P_L2_LEVELS >= (1 << 6) && + lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; } From patchwork Mon Sep 16 14:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pAj2TAAJ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8mC5Wpvz9sPn for ; Tue, 17 Sep 2019 01:09:31 +1000 (AEST) Received: from localhost ([::1]:35712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sd7-0007qS-4m for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:09:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53649) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCs-0006Ow-K2 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCr-0007Rx-0S for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:22 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54515) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCq-0007RF-3E for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:20 -0400 Received: by mail-wm1-x334.google.com with SMTP id p7so59559wmp.4 for ; Mon, 16 Sep 2019 07:42:19 -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 :mime-version:content-transfer-encoding; bh=E+2MN0bdyQ/s8snWDk5tAnhwggMh7vntuwQ/7buJlTc=; b=pAj2TAAJ/t4u1xKJLvN7dUtOPfvCc2EvoLUnGwcqFW1MR9J/X1IL71mqHLPO+ITYEi 9A2PNdAxZCdYNIYw2mUlAFndEDGm8Xl2H/2v49P0p5kglG7DUS2fch1zfTmHz3n96MTs Ol/nW6dTggJu+3+fTSykPviC0+k3uOrEMOFi6crWpv+1oWtaGsAUpoCuO4p0uhvN7qv2 qqgaW9ei2TJPOYiRHpZe3Sfahr+z7PB+cwJg8jaowmiWwCO0dkiqanF+1Ye9hZlXqON7 aqNCXML9gPNb4idDFU//P6vs/ROpx5glJ50eAiD7DfB/eaI/R52Kr361S6ShMASN1ybi rAmQ== 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:mime-version:content-transfer-encoding; bh=E+2MN0bdyQ/s8snWDk5tAnhwggMh7vntuwQ/7buJlTc=; b=ENPPiWm3C5+Edwby5rKewwH4O95ql8t81qYETBFXCDlYSb280kj0VRlLK3Lf8Hg/GF 5s+FR7M7kQCT9muDsdmk/f9B/5VybednhvPfV0PeeB5vFlN5wrsFcqRFvO6B/r+5xdpJ DifmORvHprWfiKYkT9V4y1PvyzE7fjAfPg9cFUz/t2IYs62NDCUqSG9K5R18z/FnNm+s uVFkrL4r1bjB8k44oOvnwCQeCicT9pwgo/nNLJ7tOlmcFWZa0IB7W/EIns5AsMzK1THa +0Gh+Fvq9QvdQrLHg/tMismBPte+Rq4z+elB2Ay58DriJqdVgC2EF6iheJApea+69JiU XGsQ== X-Gm-Message-State: APjAAAVx+T0NA9CAWlBAc/bAAYtTRJRY/OXty+gG/jE1OeUDYfYC/yZg OtWwb6mxMbbCeGpRI4pTEelyXJhg X-Google-Smtp-Source: APXvYqwhFYWbg+JSV1g5vTmwBxvsqoxikxCR0ExmPZgdt6VCWXflYS0U7GROgzyyAUGzCCJ90qZI8A== X-Received: by 2002:a7b:c3c6:: with SMTP id t6mr45589wmj.5.1568644937697; Mon, 16 Sep 2019 07:42:17 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:47 +0200 Message-Id: <1568644929-9124-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 07/29] win32: fix README file in NSIS installer 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Adjust after the rST conversion and consequent renaming. Fixes: 336a7451e8803c21a2da6e7d1eca8cfb8e8b219a Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Paolo Bonzini --- qemu.nsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu.nsi b/qemu.nsi index d0df0f4..0c29ba3 100644 --- a/qemu.nsi +++ b/qemu.nsi @@ -119,7 +119,7 @@ Section "${PRODUCT} (required)" File "${SRCDIR}\Changelog" File "${SRCDIR}\COPYING" File "${SRCDIR}\COPYING.LIB" - File "${SRCDIR}\README" + File "${SRCDIR}\README.rst" File "${SRCDIR}\VERSION" File "${BINDIR}\*.bmp" @@ -211,7 +211,7 @@ Section "Uninstall" Delete "$INSTDIR\Changelog" Delete "$INSTDIR\COPYING" Delete "$INSTDIR\COPYING.LIB" - Delete "$INSTDIR\README" + Delete "$INSTDIR\README.rst" Delete "$INSTDIR\VERSION" Delete "$INSTDIR\*.bmp" Delete "$INSTDIR\*.bin" From patchwork Mon Sep 16 14:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mbhpu5QA"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8nn06Gyz9sPn for ; Tue, 17 Sep 2019 01:10:53 +1000 (AEST) Received: from localhost ([::1]:35738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9seQ-00016G-3S for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:10:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCt-0006Pv-E5 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCr-0007SE-Fh for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:23 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:36236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCr-0007RY-13 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:21 -0400 Received: by mail-wm1-x341.google.com with SMTP id t3so93308wmj.1 for ; Mon, 16 Sep 2019 07:42:20 -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 :mime-version:content-transfer-encoding; bh=F4wjmLu6wuZ6WJhZD7UWKZMQnvS2jTIE8u3K4MLhVWQ=; b=mbhpu5QAHOCssMBDfqtlJziMfjn25KRIhVkTsnl0O2ncaYjFteTZ9UEGgWShkr5fPj 9wzLSc94alTmmlxxhMKpCcdOJ1sghI/0q1fkdJJN21t1I45kXQwPzL7v9LHjqRYey62G RyzavzUz7G4QwY5ApIh7mO42Z7LKj6l1d4TEEBX5+aBCzDkfTDMdW9aLbobdN+Pwb4f7 WT0kiDZGph3sF150qo6BMuGCjI6mMTvZ+bRn+gsbdebjcLbapj3/+okmIdqn4COgKZoh U+o69p6kUVqCeSU+rnAilhbqywDLz/Gk/JPRqKiMjJvbiatWBwlYA+pyba7Swf2F5sU6 C9xg== 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:mime-version:content-transfer-encoding; bh=F4wjmLu6wuZ6WJhZD7UWKZMQnvS2jTIE8u3K4MLhVWQ=; b=m+ImBUMmutLiyXXXXWkIXplSSVHnw6hJAeeC8xSCPCmBd+9bDJlDUerlteCRM+EPQG fevIYxFcyrrikh4P6YOJJRYuSDSUKySo5+SEsbA9kyQklh7RJN2+X098Fw8vIc07b7PD lqdeSgpfbaj2O5rDzB1q8kCBHF6kGmzpDy8HroH6KGBAYpMJ+7aLnNvutYNY5i0do9dr 4rLXxwJUC25Li2/jrbnazcoZEYmo7WtJ9XHqP/0VvRfVGwOmDHgJaLx1R6++VA29y95F vczCWjRVRqFbBu1rkWwvQ/ysbXRqP4951aZ5EScoTmY1Q/9vANH7SerVfeK35yPLjjAn k5vw== X-Gm-Message-State: APjAAAVLVk7n+bScZEUfAQpcLPAvAkJKhK9C7z+G7F4gA9utLlQA7ab+ hsuRSoClDO49aizOW/hBqOK8xYFY X-Google-Smtp-Source: APXvYqz2wAhyVT/GjPs4CsjHxDaX5hCvcviCu6f1dAsPMOPEPl4c1/XhZPppaIVDqI3RJUpuItZZnQ== X-Received: by 2002:a1c:c104:: with SMTP id r4mr73645wmf.64.1568644939165; Mon, 16 Sep 2019 07:42:19 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:48 +0200 Message-Id: <1568644929-9124-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PULL 08/29] test-char: fix AddressSanitizer failure 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The CharSocketServerTestConfig and CharSocketClientTestConfig objects escape after they are passed to g_test_add_data_func, but they cease existing after the scope that defines them is closed. Make them static to fix this issue. Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Paolo Bonzini --- tests/test-char.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test-char.c b/tests/test-char.c index f3ebdff..d62de1b 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -1355,6 +1355,18 @@ static void char_hotswap_test(void) g_free(chr_args); } +static SocketAddress tcpaddr = { + .type = SOCKET_ADDRESS_TYPE_INET, + .u.inet.host = (char *)"127.0.0.1", + .u.inet.port = (char *)"0", +}; +#ifndef WIN32 +static SocketAddress unixaddr = { + .type = SOCKET_ADDRESS_TYPE_UNIX, + .u.q_unix.path = (char *)"test-char.sock", +}; +#endif + int main(int argc, char **argv) { bool has_ipv4, has_ipv6; @@ -1390,26 +1402,14 @@ int main(int argc, char **argv) g_test_add_func("/char/file-fifo", char_file_fifo_test); #endif - SocketAddress tcpaddr = { - .type = SOCKET_ADDRESS_TYPE_INET, - .u.inet.host = (char *)"127.0.0.1", - .u.inet.port = (char *)"0", - }; -#ifndef WIN32 - SocketAddress unixaddr = { - .type = SOCKET_ADDRESS_TYPE_UNIX, - .u.q_unix.path = (char *)"test-char.sock", - }; -#endif - #define SOCKET_SERVER_TEST(name, addr) \ - CharSocketServerTestConfig server1 ## name = \ + static CharSocketServerTestConfig server1 ## name = \ { addr, false, false }; \ - CharSocketServerTestConfig server2 ## name = \ + static CharSocketServerTestConfig server2 ## name = \ { addr, true, false }; \ - CharSocketServerTestConfig server3 ## name = \ + static CharSocketServerTestConfig server3 ## name = \ { addr, false, true }; \ - CharSocketServerTestConfig server4 ## name = \ + static CharSocketServerTestConfig server4 ## name = \ { addr, true, true }; \ g_test_add_data_func("/char/socket/server/mainloop/" # name, \ &server1 ##name, char_socket_server_test); \ @@ -1421,17 +1421,17 @@ int main(int argc, char **argv) &server4 ##name, char_socket_server_test) #define SOCKET_CLIENT_TEST(name, addr) \ - CharSocketClientTestConfig client1 ## name = \ + static CharSocketClientTestConfig client1 ## name = \ { addr, NULL, false, false }; \ - CharSocketClientTestConfig client2 ## name = \ + static CharSocketClientTestConfig client2 ## name = \ { addr, NULL, true, false }; \ - CharSocketClientTestConfig client3 ## name = \ + static CharSocketClientTestConfig client3 ## name = \ { addr, ",reconnect=1", false }; \ - CharSocketClientTestConfig client4 ## name = \ + static CharSocketClientTestConfig client4 ## name = \ { addr, ",reconnect=1", true }; \ - CharSocketClientTestConfig client5 ## name = \ + static CharSocketClientTestConfig client5 ## name = \ { addr, NULL, false, true }; \ - CharSocketClientTestConfig client6 ## name = \ + static CharSocketClientTestConfig client6 ## name = \ { addr, NULL, true, true }; \ g_test_add_data_func("/char/socket/client/mainloop/" # name, \ &client1 ##name, char_socket_client_test); \ From patchwork Mon Sep 16 14:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FCxFw+xg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9P62L4Nz9sPq for ; Tue, 17 Sep 2019 01:38:02 +1000 (AEST) Received: from localhost ([::1]:35998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t4h-0002i5-Op for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:37:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53676) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCu-0006Rj-Q5 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCs-0007Se-Jj for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:24 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:34582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCs-0007SB-7k for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:22 -0400 Received: by mail-wm1-x332.google.com with SMTP id y135so189765wmc.1 for ; Mon, 16 Sep 2019 07:42: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; bh=GX4JaDIbHHodc8bsVUgp1wGeHcMPOFe7Qx97BWjaFus=; b=FCxFw+xghXiUmKYNhE198znwVLIUZda2m/8UBJJgbDBcLRsPQjbEdx1kvjU0oUHkiA RSyDqqnqhqoVGj0PUf6hb4RpT/Kx8IDymD3Z5go/2K/ZYYqr3iYvo5RskL5dCGF4LZc7 /VUUzm9Qd2H5McNfNj1qzvSvseDSbSstr5ynJZIvm3I9zRoAzkBPfOMramMYJAXKWLAJ 53fxp+PFjxZ+Rf37+OP7eueu09jPvRycRypQi82/L7KNQNzz431NVc9PX3H9O0YGE194 tSPFlYz80Y9KrWRJbu7QFGmlRKdnfomT8W2ThBfFIHOZvqy9KXx8mU/W65F2S3qEP3VQ mvdg== 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=GX4JaDIbHHodc8bsVUgp1wGeHcMPOFe7Qx97BWjaFus=; b=k4EWq5FsksboCmsVs20wQA9i+htDm5wRtWDvrdouVOX4AKvO5pMRFpHagR0xAghwIK JG/nEaU5oF2BAMMQZnyVATgDleNcZ9fLndUMBq/9OV2cm9OSzQehdbxgYaJig6CpMKXD yKycnrnUh0oLtRHz51vd5xkbM0oTQyRIvmARcXgSi2wWNBcVoUF3LxHKT9O+5meahgZ/ 2WPo+UQT/68SAU2Tqj71sZWQ9ISQCXzF1/T8xPaypHukyx/bKtt23Irkxev4g0DRTAIa InxXML2hejbmOQBeQ6aPliMcH6SGC+cxUktNE+N6gnIUBHPoxPvJmIMQrljv8mUvdYkn dMwA== X-Gm-Message-State: APjAAAUKJId6TMJsLeUAOCi1HhXJamM0l9RZBDyCx9QEDBI19PpILu36 VByapI5TDwP7EfJubyZwiBmZYe2C X-Google-Smtp-Source: APXvYqxflfHNVMG4M5fWxYGBMUT75qzIWMA+KkazjPNnyJE11t5I9klrxJDesHGcJ65usyS36xoOxg== X-Received: by 2002:a1c:3b06:: with SMTP id i6mr80372wma.6.1568644940650; Mon, 16 Sep 2019 07:42:20 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:49 +0200 Message-Id: <1568644929-9124-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::332 Subject: [Qemu-devel] [PULL 09/29] hw/i386: Move CONFIG_ACPI_PCI to CONFIG_PC 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: Cole Robinson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cole Robinson CONFIG_ACPI_PCI is a hard requirement of acpi-build.c, which is built unconditionally for x86 target. Putting it in default-configs/ suggests that it can be easily disabled, which isn't true. Relocate the symbol with the other acpi-build.c requirements, under 'config PC'. This is similar to what is done for the arm 'virt' machine type and CONFIG_ACPI_PCI Signed-off-by: Cole Robinson Message-Id: Signed-off-by: Paolo Bonzini --- default-configs/i386-softmmu.mak | 1 - hw/i386/Kconfig | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index cd5ea39..ba3fb3f 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -25,4 +25,3 @@ CONFIG_ISAPC=y CONFIG_I440FX=y CONFIG_Q35=y -CONFIG_ACPI_PCI=y diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 6350438..c7a9d63 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -29,6 +29,7 @@ config PC select MC146818RTC # For ACPI builder: select SERIAL_ISA + select ACPI_PCI select ACPI_VMGENID select VIRTIO_PMEM_SUPPORTED From patchwork Mon Sep 16 14:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jmRlYKG5"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8r34nF9z9sPn for ; Tue, 17 Sep 2019 01:12:51 +1000 (AEST) Received: from localhost ([::1]:35756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sgK-0003Ty-8V for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:12:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53698) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCw-0006U9-IT for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCu-0007Tb-G2 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:26 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:35467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCt-0007Sq-Rc for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:24 -0400 Received: by mail-wm1-x32d.google.com with SMTP id y21so103188wmi.0 for ; Mon, 16 Sep 2019 07:42:23 -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=fWK7xkNMUlgfTrhGnvGuIYUCcAtGnQSBVV6UtaSG9/g=; b=jmRlYKG5kXGqlNC6hKtUuZNj0FM9tuKyfuptebwfpg6zPqES+Fg2Ka3u+nLvAr6paY mZc4MU2P5RDoYxZa6Fq9woKWGaYrAOC4fWkKz3zRxNd0vYwlDT1pagApJUO6TDrNcuto PqQLGc/CxO/SzNAMEwhYdnxwt35a6jpxxgaLat1t2TZ+kV5PGPxa67SmkJYYusMrO0ig UXMGQN6/pXAqm+TQaToyCCS80iNS7Xq1BqG0tVlmw8dlbVmywS2WNyaLPlW09pq+T8ob apE2y46OPNMAXwVCIZTr8x34xlbdQUYuLaRI7aru5iRS7e9iqGOGrBkBePWrWY2Ggvta 6vxw== 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=fWK7xkNMUlgfTrhGnvGuIYUCcAtGnQSBVV6UtaSG9/g=; b=STszWHDcsIH9FO8gn8Wrc6Vw8HNHcPgSTULiVFX0U4T5foDeUHwpPQ41DRADMevPIh Q5ugD5wtFT4n/NwXqcc1TMGZrOs++UrRFdV0Uz9VkDOOG11Elfjt0kSBhfVRDtIscBlm fOAsEija/gHJIOaDeVvi7xK4TBlgeHdQEWjF3j56sPV6udqdkB5Nf6OdO1FmaIxknJ3k GIUvXvLl3uXrIn9AStbSHrkRkv8v6M+f9CPu2u90PopYFlzXkx8CjemZOhvW5876I0n9 NUHZrm8gyv8RI2JI+u6AdMuwjYNrTUYsm4WdKTtMKfAOZjVH1NNkeY5c5uzLWTbUq3qQ Uk+g== X-Gm-Message-State: APjAAAVZ0F4FA+lsqbPbEAn1xpE9pAE23W2oj8hccHXJY40ppXDyPtXJ HzNjUV97X55pCZQOf57l1mH3Mlhs X-Google-Smtp-Source: APXvYqzh5s6MT4f2NjdJLxsUHrH+oqa8OhIjoNL2rBvlQcq6FBwNIV5+D3KsIeGsNn3gYAjKCuTDyA== X-Received: by 2002:a7b:c247:: with SMTP id b7mr24953wmj.121.1568644941886; Mon, 16 Sep 2019 07:42:21 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:50 +0200 Message-Id: <1568644929-9124-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d Subject: [Qemu-devel] [PULL 10/29] elf-ops.h: fix int overflow in load_elf() 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: Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefano Garzarella This patch fixes a possible integer overflow when we calculate the total size of ELF segments loaded. Reported-by: Coverity (CID 1405299) Reviewed-by: Alex Bennée Signed-off-by: Stefano Garzarella Message-Id: <20190910124828.39794-1-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/loader.c | 2 ++ include/hw/elf_ops.h | 5 +++++ include/hw/loader.h | 1 + 3 files changed, 8 insertions(+) diff --git a/hw/core/loader.c b/hw/core/loader.c index 32f7cc7..75eb56d 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -338,6 +338,8 @@ const char *load_elf_strerror(int error) return "The image is from incompatible architecture"; case ELF_LOAD_WRONG_ENDIAN: return "The image has incorrect endianness"; + case ELF_LOAD_TOO_BIG: + return "The image segments are too big to load"; default: return "Unknown error"; } diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 1496d7e..e07d276 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -485,6 +485,11 @@ static int glue(load_elf, SZ)(const char *name, int fd, } } + if (mem_size > INT_MAX - total_size) { + ret = ELF_LOAD_TOO_BIG; + goto fail; + } + /* address_offset is hack for kernel images that are linked at the wrong physical address. */ if (translate_fn) { diff --git a/include/hw/loader.h b/include/hw/loader.h index 07fd928..48a96cd 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -89,6 +89,7 @@ int load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz); #define ELF_LOAD_NOT_ELF -2 #define ELF_LOAD_WRONG_ARCH -3 #define ELF_LOAD_WRONG_ENDIAN -4 +#define ELF_LOAD_TOO_BIG -5 const char *load_elf_strerror(int error); /** load_elf_ram_sym: From patchwork Mon Sep 16 14:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OMOU6mtr"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9Tf1lTCz9sPq for ; Tue, 17 Sep 2019 01:41:58 +1000 (AEST) Received: from localhost ([::1]:36052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t8T-0007Gb-R3 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:41:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53715) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCy-0006WQ-8R for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCv-0007UB-Oq for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:28 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCu-0007TP-VM for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id r5so5213255wrm.12 for ; Mon, 16 Sep 2019 07:42: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; bh=15ASw7Sda32hAHbQApt0nrRp6KAHHCRUIPuWH1EYvBg=; b=OMOU6mtrfGuxY/0J7L+RmnKRgwzrrpCXLBu1CTTFUIFVF1eb0j3pD0cuxjpAhVyWJ1 w/y/BRDuqD8UvJYB6FuQypcnZbma6V8Jwmzx5b4e9oKrF1UQPDUhwUqzQ7X87iH9L3m+ QrzGSeVx5RuSIB1Q9qgehlSIZOeYJjC4DIZBuToDrX/Z03y0LW1Supn7p9wEV+Z3N7kf HWVbHwZihD5yZNvY+xradXxJkL1vePQSa3JXR75X3P7ytm6bHW5tVDjbiA2LzJsg2yRE am5Cby3z04DOgYRm3++Q6ecv0CgsoIz1lmqN0MhMbHPRBOVxrAmHW7qjrnkmh6mRiBHa kY5Q== 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=15ASw7Sda32hAHbQApt0nrRp6KAHHCRUIPuWH1EYvBg=; b=DrJYvGzUauly16a2roQu5RYqnzSuUU+AJCr6wjDISCXneEJCrIOC5I5bEvkU3snZP8 hChMN8HYW0YdbhJ+w9LBWHhyE5oR4yAM6E1ifbz9hdfHcOdMS0BVggMKMjlLeMeMv8Od Z+BFTAmLvw8nzuA0MWmRUzOx9pQ1cdqyWqKBSG8qRiVEdbcPnFEXdt4ffuTIQrl2tIes n6Coi80iW29reVnhPu18SzfMVga57crSU5bDIM2jPs59xmOurGzVUB0jOtq0XcR8z1nk 9p6oOIG9bAtuag8B2+QdH7d64QCIlkbCoj/S2LaCDeEjcCwJVmQa7AdV68IiW5V0skq1 lemA== X-Gm-Message-State: APjAAAUBrr8anK6wBLwnoiROMt0kGPDXNpXJcn7wtjmFLS+Km9TZ35rz EIwC/oB4iAmn0eYJl4EEVs1j2LMY X-Google-Smtp-Source: APXvYqw2adYeU9ECLXlFSIAwn/FLPlPa0xwiPidSvx5xC1vhMCYPmb/IE3hRwcpqudxOTAg1I24pQQ== X-Received: by 2002:a5d:548d:: with SMTP id h13mr93168wrv.215.1568644943237; Mon, 16 Sep 2019 07:42:23 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:51 +0200 Message-Id: <1568644929-9124-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::444 Subject: [Qemu-devel] [PULL 11/29] memory: fetch pmem size in get_file_size() 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: Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Neither stat(2) nor lseek(2) report the size of Linux devdax pmem character device nodes. Commit 314aec4a6e06844937f1677f6cba21981005f389 ("hostmem-file: reject invalid pmem file sizes") added code to hostmem-file.c to fetch the size from sysfs and compare against the user-provided size=NUM parameter: if (backend->size > size) { error_setg(errp, "size property %" PRIu64 " is larger than " "pmem file \"%s\" size %" PRIu64, backend->size, fb->mem_path, size); return; } It turns out that exec.c:qemu_ram_alloc_from_fd() already has an equivalent size check but it skips devdax pmem character devices because lseek(2) returns 0: if (file_size > 0 && file_size < size) { error_setg(errp, "backing store %s size 0x%" PRIx64 " does not match 'size' option 0x" RAM_ADDR_FMT, mem_path, file_size, size); return NULL; } This patch moves the devdax pmem file size code into get_file_size() so that we check the memory size in a single place: qemu_ram_alloc_from_fd(). This simplifies the code and makes it more general. This also fixes the problem that hostmem-file only checks the devdax pmem file size when the pmem=on parameter is given. An unchecked size=NUM parameter can lead to SIGBUS in QEMU so we must always fetch the file size for Linux devdax pmem character device nodes. Signed-off-by: Stefan Hajnoczi Message-Id: <20190830093056.12572-1-stefanha@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- backends/hostmem-file.c | 22 -------------------- exec.c | 34 ++++++++++++++++++++++++++++++- include/qemu/osdep.h | 13 ------------ util/oslib-posix.c | 54 ------------------------------------------------- util/oslib-win32.c | 6 ------ 5 files changed, 33 insertions(+), 96 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index ecc15e3..be64020 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -58,28 +58,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) return; } - /* - * Verify pmem file size since starting a guest with an incorrect size - * leads to confusing failures inside the guest. - */ - if (fb->is_pmem) { - Error *local_err = NULL; - uint64_t size; - - size = qemu_get_pmem_size(fb->mem_path, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - if (size && backend->size > size) { - error_setg(errp, "size property %" PRIu64 " is larger than " - "pmem file \"%s\" size %" PRIu64, backend->size, - fb->mem_path, size); - return; - } - } - backend->force_prealloc = mem_prealloc; name = host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), diff --git a/exec.c b/exec.c index b9511be..8b99897 100644 --- a/exec.c +++ b/exec.c @@ -1791,7 +1791,39 @@ long qemu_maxrampagesize(void) #ifdef CONFIG_POSIX static int64_t get_file_size(int fd) { - int64_t size = lseek(fd, 0, SEEK_END); + int64_t size; +#if defined(__linux__) + struct stat st; + + if (fstat(fd, &st) < 0) { + return -errno; + } + + /* Special handling for devdax character devices */ + if (S_ISCHR(st.st_mode)) { + g_autofree char *subsystem_path = NULL; + g_autofree char *subsystem = NULL; + + subsystem_path = g_strdup_printf("/sys/dev/char/%d:%d/subsystem", + major(st.st_rdev), minor(st.st_rdev)); + subsystem = g_file_read_link(subsystem_path, NULL); + + if (subsystem && g_str_has_suffix(subsystem, "/dax")) { + g_autofree char *size_path = NULL; + g_autofree char *size_str = NULL; + + size_path = g_strdup_printf("/sys/dev/char/%d:%d/size", + major(st.st_rdev), minor(st.st_rdev)); + + if (g_file_get_contents(size_path, &size_str, NULL, NULL)) { + return g_ascii_strtoll(size_str, NULL, 0); + } + } + } +#endif /* defined(__linux__) */ + + /* st.st_size may be zero for special files yet lseek(2) works */ + size = lseek(fd, 0, SEEK_END); if (size < 0) { return -errno; } diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index af2b91f..c7d242f 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -571,19 +571,6 @@ void os_mem_prealloc(int fd, char *area, size_t sz, int smp_cpus, Error **errp); /** - * qemu_get_pmem_size: - * @filename: path to a pmem file - * @errp: pointer to a NULL-initialized error object - * - * Determine the size of a persistent memory file. Besides supporting files on - * DAX file systems, this function also supports Linux devdax character - * devices. - * - * Returns: the size or 0 on failure - */ -uint64_t qemu_get_pmem_size(const char *filename, Error **errp); - -/** * qemu_get_pid_name: * @pid: pid of a process * diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 5fda67d..f869338 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -514,60 +514,6 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, } } -uint64_t qemu_get_pmem_size(const char *filename, Error **errp) -{ - struct stat st; - - if (stat(filename, &st) < 0) { - error_setg(errp, "unable to stat pmem file \"%s\"", filename); - return 0; - } - -#if defined(__linux__) - /* Special handling for devdax character devices */ - if (S_ISCHR(st.st_mode)) { - char *subsystem_path = NULL; - char *subsystem = NULL; - char *size_path = NULL; - char *size_str = NULL; - uint64_t ret = 0; - - subsystem_path = g_strdup_printf("/sys/dev/char/%d:%d/subsystem", - major(st.st_rdev), minor(st.st_rdev)); - subsystem = g_file_read_link(subsystem_path, NULL); - if (!subsystem) { - error_setg(errp, "unable to read subsystem for pmem file \"%s\"", - filename); - goto devdax_err; - } - - if (!g_str_has_suffix(subsystem, "/dax")) { - error_setg(errp, "pmem file \"%s\" is not a dax device", filename); - goto devdax_err; - } - - size_path = g_strdup_printf("/sys/dev/char/%d:%d/size", - major(st.st_rdev), minor(st.st_rdev)); - if (!g_file_get_contents(size_path, &size_str, NULL, NULL)) { - error_setg(errp, "unable to read size for pmem file \"%s\"", - size_path); - goto devdax_err; - } - - ret = g_ascii_strtoull(size_str, NULL, 0); - -devdax_err: - g_free(size_str); - g_free(size_path); - g_free(subsystem); - g_free(subsystem_path); - return ret; - } -#endif /* defined(__linux__) */ - - return st.st_size; -} - char *qemu_get_pid_name(pid_t pid) { char *name = NULL; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 9583fb4..c62cd43 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -562,12 +562,6 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, } } -uint64_t qemu_get_pmem_size(const char *filename, Error **errp) -{ - error_setg(errp, "pmem support not available"); - return 0; -} - char *qemu_get_pid_name(pid_t pid) { /* XXX Implement me */ From patchwork Mon Sep 16 14:41:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JSy7hejG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9R55CMNz9sPq for ; Tue, 17 Sep 2019 01:39:45 +1000 (AEST) Received: from localhost ([::1]:36016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t6N-0004si-2o for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:39:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53716) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCy-0006WW-BG for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCw-0007UR-9E for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:28 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCv-0007Tv-PW for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:26 -0400 Received: by mail-wm1-x334.google.com with SMTP id p7so59942wmp.4 for ; Mon, 16 Sep 2019 07:42:25 -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=ChAXva6YSSYbjM1DBwPiQI1g6eo1sIJEFyhcEiZi7kE=; b=JSy7hejGmesu5b62BHq9K64RllLLtWLzWreXf5jpLzogsugar3wBaolRqbTFhsTrmL sR0XB3dZ2Vx/JPPZt48jE/wF7j2tqp0r3gC7FOV+7esKzgpVE6ShnCtM2aoqyzZ0rNe0 qLgDdQMXMFNBUhUyedMV/tBNJ2HYsROY7QUGKarkQnv1rOpGFZfFe3FXT7YYyk9hhzWD SSNYxm6K8gd5kENx/4c3goyO4qoeDqX09iI9sv7BMfuiWHmnq8ytNJkfEnBDGV0TQSCv vrpEyFTRxkR5aICuPdshqwHVq15SID5dkitCcAv74WUXEoo5OzHYywXgp+0sQn/ADa/Z z2Fw== 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=ChAXva6YSSYbjM1DBwPiQI1g6eo1sIJEFyhcEiZi7kE=; b=P5eSeVHhyWKXzaaOaVyYnKZlvbv4EwZkVYjUCLjjUmFDaIJvtmP7/cBQZV6gfwNYDr lqjs0AHiF2xwLZZHKhHH8zUBKk4UpakAEZ1EL/buvZAgO+EueBVWM3+8Q3ckhlzjKwPs jZTuUPRfaBT4S2cPVhV2GIIh4joNBAUO2R8Hw6OWxxl6UfMAyLtXCBvLFnZvoPkc05Qj aLfQ5fuJzdPGIGs0cOXNUk858xlkqRLNh4Vf/ZbEgep36hon5SB1xixaIaYrWWcFJ/y+ EU1lOhleMmaaXI+uN7YKOdUvfqgUMXkCxzLg0zA5ohfwqry2YEUheItMbmZwW8Qc7sOL RjZg== X-Gm-Message-State: APjAAAWbVT4/6uSXoqPtVphEQ3jMETojuVzu9uRmgeU8UZmZ4DAYrFXY IRiL7s14NhPucf0o4vLQbRcHEVsU X-Google-Smtp-Source: APXvYqxoI7Vn5CaNqenA49GBI/8bxScFVAXq7yKbTKt5lKmrbfX3vdbu9n2zVaQv1EOWCp/VYJEbTg== X-Received: by 2002:a1c:f30b:: with SMTP id q11mr37454wmq.57.1568644944347; Mon, 16 Sep 2019 07:42:24 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:52 +0200 Message-Id: <1568644929-9124-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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 Subject: [Qemu-devel] [PULL 12/29] memory: inline and optimize devend_memop 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" devend_memop can rely on the fact that the result is always either 0 or MO_BSWAP, corresponding respectively to host endianness and the opposite. Native (target) endianness in turn can be either the host endianness, in which case MO_BSWAP is only returned for host-opposite endianness, or the opposite, in which case 0 is only returned for host endianness. With this in mind, devend_memop can be compiled as a setcond+shift for every target. Do this and, while at it, move it to include/exec/memory.h since !NEED_CPU_H files do not (and should not) need it. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 19 ++++++++++++++++++- memory.c | 18 ------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 2dd8102..a30245c 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2201,8 +2201,25 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr, } } +#ifdef NEED_CPU_H /* enum device_endian to MemOp. */ -MemOp devend_memop(enum device_endian end); +static inline MemOp devend_memop(enum device_endian end) +{ + QEMU_BUILD_BUG_ON(DEVICE_HOST_ENDIAN != DEVICE_LITTLE_ENDIAN && + DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN); + +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + /* Swap if non-host endianness or native (target) endianness */ + return (end == DEVICE_HOST_ENDIAN) ? 0 : MO_BSWAP; +#else + const int non_host_endianness = + DEVICE_LITTLE_ENDIAN ^ DEVICE_BIG_ENDIAN ^ DEVICE_HOST_ENDIAN; + + /* In this case, native (target) endianness needs no swap. */ + return (end == non_host_endianness) ? MO_BSWAP : 0; +#endif +} +#endif #endif diff --git a/memory.c b/memory.c index 61a254c..b9dd6b9 100644 --- a/memory.c +++ b/memory.c @@ -3267,21 +3267,3 @@ static void memory_register_types(void) } type_init(memory_register_types) - -MemOp devend_memop(enum device_endian end) -{ - static MemOp conv[] = { - [DEVICE_LITTLE_ENDIAN] = MO_LE, - [DEVICE_BIG_ENDIAN] = MO_BE, - [DEVICE_NATIVE_ENDIAN] = MO_TE, - [DEVICE_HOST_ENDIAN] = 0, - }; - switch (end) { - case DEVICE_LITTLE_ENDIAN: - case DEVICE_BIG_ENDIAN: - case DEVICE_NATIVE_ENDIAN: - return conv[end]; - default: - g_assert_not_reached(); - } -} From patchwork Mon Sep 16 14:41:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vVRi1n1F"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8x43d5rz9sPn for ; Tue, 17 Sep 2019 01:17:12 +1000 (AEST) Received: from localhost ([::1]:35790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9skY-0007Ec-C0 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:17:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53732) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCz-0006YF-Mn for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCx-0007Uv-D2 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:29 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCw-0007UP-Tl for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:27 -0400 Received: by mail-wr1-x443.google.com with SMTP id i1so38605971wro.4 for ; Mon, 16 Sep 2019 07:42: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; bh=/9mBH+AAUSSLGhvpwHNCY+2vRoaPSjC+sHXPNN0R2GE=; b=vVRi1n1Fo7h1bTbe9nLJNBdtxVfAITHMCIjx+iHSNzlhZ5RL10SD/Acjv6yzQP1NOX BGuEX9Q0/pphMhxpYgU/7BuqttF0FsUDahOPsTrRxfwxMfTIWLj7/D5NF4/GKo217WxG ej3CCOYHw5LrhcdpmtcBkJgXWiUii1xWJ4TjfIpCsgj1vJtzKzUw9n73sSePPcG08KRh Y+PPGDKJbhlXJobyJWgk3tKd3LY68Ap1dHoW4GGfOuAMHlw8/OWCf8MhteIizAKRuKuZ 3YJp9+7Q5TFqa5ecybbyW2CwFWYj4sBbuH+SVLmtAhV/K059rNR1k6FaxDwLG5+Ifzsv JZtQ== 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=/9mBH+AAUSSLGhvpwHNCY+2vRoaPSjC+sHXPNN0R2GE=; b=nZmn6C47QFHG4/OkowReVCD47N6jcNWDavWjvyEhBjKiKbPclLFUyCzR1gqvBlz5Qg 2T0YhoRqitcqwTSqGHZkuAr5kMHIuL1wng1T9PvKP3BF13m0v1Yqrnuz+L/BAHyJxiGN W2dpEXFi75oAhec2O4hXKKmHN32lVW8RLKbL4q58+4oWRlmVHXeXhmJS999/h2ujEBbK oOPC2D0RcVwLiZcMTjB6OSzqNOa+AycgWhsdkusPl/V+GJK+A2Wiw9CLqSL6dZ/l8c3x bTPyjRbXMGnltNc9qupHev84GlPumdOYG2ofVvTu1vOLxf0OsnH6mdcU3a4hos9bH9F5 j84A== X-Gm-Message-State: APjAAAU5yKEL6PhFhINsdbFpDxnhvQ9QglToQSRswXOMbAhL7Yaly1xp h6GkOWBd4jSMqQibFy0Bl4VX04or X-Google-Smtp-Source: APXvYqzeBhoCUGIKG4O/kVauOIf5Z2URiXuE8eYG/fvDasKAZtTcJB6+icvc86JO5p3EIpFstsFEJA== X-Received: by 2002:adf:b3c1:: with SMTP id x1mr109032wrd.33.1568644945435; Mon, 16 Sep 2019 07:42:25 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:53 +0200 Message-Id: <1568644929-9124-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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::443 Subject: [Qemu-devel] [PULL 13/29] qemu-thread: Add qemu_cond_timedwait 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: Yury Kotov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yury Kotov The new function is needed to implement conditional sleep for CPU throttling. It's possible to reuse qemu_sem_timedwait, but it's more difficult than just add qemu_cond_timedwait. Also moved compute_abs_deadline function up the code to reuse it in qemu_cond_timedwait_impl win32. Signed-off-by: Yury Kotov Message-Id: <20190909131335.16848-2-yury-kotov@yandex-team.ru> --- include/qemu/thread.h | 19 +++++++++++++++++++ util/qemu-thread-posix.c | 41 +++++++++++++++++++++++++++++------------ util/qemu-thread-win32.c | 17 +++++++++++++++++ util/qsp.c | 20 ++++++++++++++++++++ 4 files changed, 85 insertions(+), 12 deletions(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index 55d83a9..047db03 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -34,6 +34,8 @@ typedef void (*QemuRecMutexLockFunc)(QemuRecMutex *m, const char *f, int l); typedef int (*QemuRecMutexTrylockFunc)(QemuRecMutex *m, const char *f, int l); typedef void (*QemuCondWaitFunc)(QemuCond *c, QemuMutex *m, const char *f, int l); +typedef bool (*QemuCondTimedWaitFunc)(QemuCond *c, QemuMutex *m, int ms, + const char *f, int l); extern QemuMutexLockFunc qemu_bql_mutex_lock_func; extern QemuMutexLockFunc qemu_mutex_lock_func; @@ -41,6 +43,7 @@ extern QemuMutexTrylockFunc qemu_mutex_trylock_func; extern QemuRecMutexLockFunc qemu_rec_mutex_lock_func; extern QemuRecMutexTrylockFunc qemu_rec_mutex_trylock_func; extern QemuCondWaitFunc qemu_cond_wait_func; +extern QemuCondTimedWaitFunc qemu_cond_timedwait_func; /* convenience macros to bypass the profiler */ #define qemu_mutex_lock__raw(m) \ @@ -63,6 +66,8 @@ extern QemuCondWaitFunc qemu_cond_wait_func; qemu_rec_mutex_trylock_impl(m, __FILE__, __LINE__); #define qemu_cond_wait(c, m) \ qemu_cond_wait_impl(c, m, __FILE__, __LINE__); +#define qemu_cond_timedwait(c, m, ms) \ + qemu_cond_wait_impl(c, m, ms, __FILE__, __LINE__); #else #define qemu_mutex_lock(m) ({ \ QemuMutexLockFunc _f = atomic_read(&qemu_mutex_lock_func); \ @@ -89,6 +94,11 @@ extern QemuCondWaitFunc qemu_cond_wait_func; QemuCondWaitFunc _f = atomic_read(&qemu_cond_wait_func); \ _f(c, m, __FILE__, __LINE__); \ }) + +#define qemu_cond_timedwait(c, m, ms) ({ \ + QemuCondTimedWaitFunc _f = atomic_read(&qemu_cond_timedwait_func); \ + _f(c, m, ms, __FILE__, __LINE__); \ + }) #endif #define qemu_mutex_unlock(mutex) \ @@ -134,12 +144,21 @@ void qemu_cond_signal(QemuCond *cond); void qemu_cond_broadcast(QemuCond *cond); void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *file, const int line); +bool qemu_cond_timedwait_impl(QemuCond *cond, QemuMutex *mutex, int ms, + const char *file, const int line); static inline void (qemu_cond_wait)(QemuCond *cond, QemuMutex *mutex) { qemu_cond_wait(cond, mutex); } +/* Returns true if timeout has not expired, and false otherwise */ +static inline bool (qemu_cond_timedwait)(QemuCond *cond, QemuMutex *mutex, + int ms) +{ + return qemu_cond_timedwait(cond, mutex, ms); +} + void qemu_sem_init(QemuSemaphore *sem, int init); void qemu_sem_post(QemuSemaphore *sem); void qemu_sem_wait(QemuSemaphore *sem); diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 1bf5e65..838980a 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -36,6 +36,18 @@ static void error_exit(int err, const char *msg) abort(); } +static void compute_abs_deadline(struct timespec *ts, int ms) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + ts->tv_nsec = tv.tv_usec * 1000 + (ms % 1000) * 1000000; + ts->tv_sec = tv.tv_sec + ms / 1000; + if (ts->tv_nsec >= 1000000000) { + ts->tv_sec++; + ts->tv_nsec -= 1000000000; + } +} + void qemu_mutex_init(QemuMutex *mutex) { int err; @@ -164,6 +176,23 @@ void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *file, con error_exit(err, __func__); } +bool qemu_cond_timedwait_impl(QemuCond *cond, QemuMutex *mutex, int ms, + const char *file, const int line) +{ + int err; + struct timespec ts; + + assert(cond->initialized); + trace_qemu_mutex_unlock(mutex, file, line); + compute_abs_deadline(&ts, ms); + err = pthread_cond_timedwait(&cond->cond, &mutex->lock, &ts); + trace_qemu_mutex_locked(mutex, file, line); + if (err && err != ETIMEDOUT) { + error_exit(err, __func__); + } + return err != ETIMEDOUT; +} + void qemu_sem_init(QemuSemaphore *sem, int init) { int rc; @@ -238,18 +267,6 @@ void qemu_sem_post(QemuSemaphore *sem) #endif } -static void compute_abs_deadline(struct timespec *ts, int ms) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - ts->tv_nsec = tv.tv_usec * 1000 + (ms % 1000) * 1000000; - ts->tv_sec = tv.tv_sec + ms / 1000; - if (ts->tv_nsec >= 1000000000) { - ts->tv_sec++; - ts->tv_nsec -= 1000000000; - } -} - int qemu_sem_timedwait(QemuSemaphore *sem, int ms) { int rc; diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c index 572f885..56a8333 100644 --- a/util/qemu-thread-win32.c +++ b/util/qemu-thread-win32.c @@ -145,6 +145,23 @@ void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *file, con qemu_mutex_post_lock(mutex, file, line); } +bool qemu_cond_timedwait_impl(QemuCond *cond, QemuMutex *mutex, int ms, + const char *file, const int line) +{ + int rc = 0; + + assert(cond->initialized); + trace_qemu_mutex_unlock(mutex, file, line); + if (!SleepConditionVariableSRW(&cond->var, &mutex->lock, ms, 0)) { + rc = GetLastError(); + } + trace_qemu_mutex_locked(mutex, file, line); + if (rc && rc != ERROR_TIMEOUT) { + error_exit(rc, __func__); + } + return rc != ERROR_TIMEOUT; +} + void qemu_sem_init(QemuSemaphore *sem, int init) { /* Manual reset. */ diff --git a/util/qsp.c b/util/qsp.c index 5264c97..6226541 100644 --- a/util/qsp.c +++ b/util/qsp.c @@ -131,6 +131,7 @@ QemuRecMutexLockFunc qemu_rec_mutex_lock_func = qemu_rec_mutex_lock_impl; QemuRecMutexTrylockFunc qemu_rec_mutex_trylock_func = qemu_rec_mutex_trylock_impl; QemuCondWaitFunc qemu_cond_wait_func = qemu_cond_wait_impl; +QemuCondTimedWaitFunc qemu_cond_timedwait_func = qemu_cond_timedwait_impl; /* * It pays off to _not_ hash callsite->file; hashing a string is slow, and @@ -412,6 +413,23 @@ qsp_cond_wait(QemuCond *cond, QemuMutex *mutex, const char *file, int line) qsp_entry_record(e, t1 - t0); } +static bool +qsp_cond_timedwait(QemuCond *cond, QemuMutex *mutex, int ms, + const char *file, int line) +{ + QSPEntry *e; + int64_t t0, t1; + bool ret; + + t0 = get_clock(); + ret = qemu_cond_timedwait_impl(cond, mutex, ms, file, line); + t1 = get_clock(); + + e = qsp_entry_get(cond, file, line, QSP_CONDVAR); + qsp_entry_record(e, t1 - t0); + return ret; +} + bool qsp_is_enabled(void) { return atomic_read(&qemu_mutex_lock_func) == qsp_mutex_lock; @@ -425,6 +443,7 @@ void qsp_enable(void) atomic_set(&qemu_rec_mutex_lock_func, qsp_rec_mutex_lock); atomic_set(&qemu_rec_mutex_trylock_func, qsp_rec_mutex_trylock); atomic_set(&qemu_cond_wait_func, qsp_cond_wait); + atomic_set(&qemu_cond_timedwait_func, qsp_cond_timedwait); } void qsp_disable(void) @@ -435,6 +454,7 @@ void qsp_disable(void) atomic_set(&qemu_rec_mutex_lock_func, qemu_rec_mutex_lock_impl); atomic_set(&qemu_rec_mutex_trylock_func, qemu_rec_mutex_trylock_impl); atomic_set(&qemu_cond_wait_func, qemu_cond_wait_impl); + atomic_set(&qemu_cond_timedwait_func, qemu_cond_timedwait_impl); } static gint qsp_tree_cmp(gconstpointer ap, gconstpointer bp, gpointer up) From patchwork Mon Sep 16 14:41:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="arT9LUaG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9Yt1wfzz9sPq for ; Tue, 17 Sep 2019 01:45:38 +1000 (AEST) Received: from localhost ([::1]:36088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tC3-0003Lg-3w for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:45:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53742) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD0-0006ZJ-GB for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCy-0007VQ-NN for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:30 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38090) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCy-0007V1-8p for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:28 -0400 Received: by mail-wr1-x441.google.com with SMTP id l11so39145167wrx.5 for ; Mon, 16 Sep 2019 07:42: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; bh=cYGflcnLYW7UqqaIj7H9EUpz5deH3v/RJ+Xg1QiY1Lo=; b=arT9LUaGEBE0a/oPLB1rrIChwmhT1k9ov5UTXsM7GHYpKNdjEOcCWMyioyQl4cpjm1 cI452Abyjrws+FOvvdbuba/w2ZlHk/JtUaV3ptU44pus2FtvIaoSv7KyTbXTSJi3mr+a dPXCH7YWoPw8tRwjV37pOmqXkkwRYjvFtMD/6Rq2nmmN69mTM9sleMXK03+R+1mcFABe f3POTnpbEBa8QJtXrfMKGOvPpqs5ggCKP9OdYStgVVoNbkXewlI64299+bOL8M1wG9nr LUg4XNBVbs5KjVaPXyCFUPjGt+UfjLH715Zc3iD9dLCbLVIUfVpacRqgKdxlB8z04nvC Xj9Q== 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=cYGflcnLYW7UqqaIj7H9EUpz5deH3v/RJ+Xg1QiY1Lo=; b=Ga2qbS+3RjaPuAVEUPyINag1fyqFXDsrsCRZTYy5oslmrhKwtXzfQwI95R26HvSKWA HFqEgWzA/4lBNak1AdyxblmeKvL7X4Jf0DAARE21/vNqzruH5HXigpt5VpwkKMBHnFWz I8GrqyDvp3Q9tKj37Jsgig1LZLegtQ+KocHOf8AP0qxyhvlaMSguOZiQaQTm5bP5NsZC Q5I50k3g+mteDZCaLTuj0q/iLbptcd0T17Bqv/v6shXv8ZHVICtJypupZlpkNRW/F26a V/C4EiUpqvlAzVZRdAq0oRt/Ppvn9BmwUNQGxoF5S8mdoKYFak8vA8HPhW70mFvmIY63 lFoQ== X-Gm-Message-State: APjAAAUbKUxyFrfI2kd4jXhuxk1l90kAg6HwZ37OWo5ZKtcN7P9sa9Hj hh6NzJCX2wFAceRgM2+VsF8+JpmG X-Google-Smtp-Source: APXvYqwSiIjFdXfCQUwB5bWGHgvEECnLPIv6U22bV8ptt5N5yVIcnVNXVXcqArp/CON1CNGIayevUA== X-Received: by 2002:a5d:46cb:: with SMTP id g11mr111270wrs.268.1568644946700; Mon, 16 Sep 2019 07:42:26 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:54 +0200 Message-Id: <1568644929-9124-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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 Subject: [Qemu-devel] [PULL 14/29] cpus: Fix throttling during vm_stop 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: Yury Kotov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yury Kotov Throttling thread sleeps in VCPU thread. For high throttle percentage this sleep is more than 10ms. E.g. for 60% - 15ms, for 99% - 990ms. vm_stop() kicks all VCPUs and waits for them. It's called at the end of migration and because of the long sleep the migration downtime might be more than 100ms even for downtime-limit 1ms. Use qemu_cond_timedwait for high percentage to wake up during vm_stop. Signed-off-by: Yury Kotov Reviewed-by: Eric Blake Message-Id: <20190909131335.16848-3-yury-kotov@yandex-team.ru> --- cpus.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cpus.c b/cpus.c index 85cd451..d2c61ff 100644 --- a/cpus.c +++ b/cpus.c @@ -77,6 +77,8 @@ #endif /* CONFIG_LINUX */ +static QemuMutex qemu_global_mutex; + int64_t max_delay; int64_t max_advance; @@ -782,7 +784,7 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque) { double pct; double throttle_ratio; - long sleeptime_ns; + int64_t sleeptime_ns, endtime_ns; if (!cpu_throttle_get_percentage()) { return; @@ -790,11 +792,20 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque) pct = (double)cpu_throttle_get_percentage()/100; throttle_ratio = pct / (1 - pct); - sleeptime_ns = (long)(throttle_ratio * CPU_THROTTLE_TIMESLICE_NS); - - qemu_mutex_unlock_iothread(); - g_usleep(sleeptime_ns / 1000); /* Convert ns to us for usleep call */ - qemu_mutex_lock_iothread(); + /* Add 1ns to fix double's rounding error (like 0.9999999...) */ + sleeptime_ns = (int64_t)(throttle_ratio * CPU_THROTTLE_TIMESLICE_NS + 1); + endtime_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + sleeptime_ns; + while (sleeptime_ns > 0 && !cpu->stop) { + if (sleeptime_ns > SCALE_MS) { + qemu_cond_timedwait(cpu->halt_cond, &qemu_global_mutex, + sleeptime_ns / SCALE_MS); + } else { + qemu_mutex_unlock_iothread(); + g_usleep(sleeptime_ns / SCALE_US); + qemu_mutex_lock_iothread(); + } + sleeptime_ns = endtime_ns - qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + } atomic_set(&cpu->throttle_thread_scheduled, 0); } @@ -1172,8 +1183,6 @@ static void qemu_init_sigbus(void) } #endif /* !CONFIG_LINUX */ -static QemuMutex qemu_global_mutex; - static QemuThread io_thread; /* cpu creation */ From patchwork Mon Sep 16 14:41:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u7NIO+XV"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9X12hSdz9sPw for ; Tue, 17 Sep 2019 01:44:00 +1000 (AEST) Received: from localhost ([::1]:36076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tAU-0001Ua-4f for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53752) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD1-0006aI-Jf for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCz-0007Vh-Qr for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:31 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:34909) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCz-0007VP-Ec for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:29 -0400 Received: by mail-wr1-x42b.google.com with SMTP id v8so3820469wrt.2 for ; Mon, 16 Sep 2019 07:42: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=N0oh/2xJJWk1j4doZ9EhbFAH+Bw5VBTm7B5dvFyJxMo=; b=u7NIO+XVj3ccpipmfYTQfbR+8BRbI7a/u5aUDIvMiF+EyKgi1A+IH7Afa6svOk4Amv uuGHgIiybSfV7sVVD8kPUSO/ZrZ+WFAnwIXITRi6PGl7DqlrY1TROq0trF5e/sHnf5Db wwaYRnorvn0OYDvtLMKuuwrRwMzV379t7b6lPHKC8uSbtKxBB2OzyM1xAZZRMuGWzrFT E4d+TX2Ye8J2Nxx2TwG1Mg6NZeKA4WmwsluIRY01yuMOro5gbbviPhOnHHSnk6eIsorP 6kjIQhqBsYzbXv0A/5RKDl8K8GdxR88ffN2+3DMhQ8Tmow5wHP1EUJpk5ivYevmZtglk XxUw== 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=N0oh/2xJJWk1j4doZ9EhbFAH+Bw5VBTm7B5dvFyJxMo=; b=gcIMOYTzD4HJ0+RlWJu54jYT5YlY7ZGa+0zxoBYv1Wkvd6a6b9fRqhpHQQXTskrgFR XiIWmEDB3CPPUKnOgtDWyWUtUuEyHm7dIJ6IjO61vSfZOCjE3gKI94jfoN90p2x0JMgv iUKPt9PnDApd98PmenkHNZR1kuQJwpoP0yq4BNDtWUQUZoo568QxCSBZca7qi3TBuhtj WPXuR3CWuDlqoBZDRGld/miaRDbWFm/q0zX5HMg6xg97+kULcDpMgYEBKd3OhpPVarQw +kwdgvAfSfx8kbr6mFT54TKqzpU5W3E2Z1+WUDZ/R99iX5pCuT6Hpso5n+/ptFwnF/2w 6VKQ== X-Gm-Message-State: APjAAAW3F5+MpANyG3kWSWyHE3dCE+c5ignr3hLsJzARl1XAuM7m32MP qS4w53iXWL0gRx38/v7kKdRO08MZ X-Google-Smtp-Source: APXvYqxrb6gZxLpOdwr98FsFqFBV16qQXwNqVU1sOSTgsEk39cGHAQJ9xMHRmcgd/sa6cq9YZB+J4Q== X-Received: by 2002:adf:f112:: with SMTP id r18mr140843wro.88.1568644947938; Mon, 16 Sep 2019 07:42:27 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:55 +0200 Message-Id: <1568644929-9124-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 15/29] hw/i386/pc: Use e820_get_num_entries() to access e820_entries 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé To be able to extract the e820* code out of this file (in the next patch), access e820_entries with its correct helper. Reviewed-by: Li Qiang Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-2-philmd@redhat.com> --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bad866f..31e9c1f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1029,7 +1029,7 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms) 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_entries); + sizeof(struct e820_entry) * e820_get_num_entries()); fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); /* allocate memory for the NUMA channel: one (64bit) word for the number From patchwork Mon Sep 16 14:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UfMJi/4j"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9dc5zZWz9sPw for ; Tue, 17 Sep 2019 01:48:52 +1000 (AEST) Received: from localhost ([::1]:36122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tFB-0005bV-Ml for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53772) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD3-0006d7-Ci for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD1-0007WC-1v for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:33 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:42420) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD0-0007Vm-MX for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:30 -0400 Received: by mail-wr1-x42e.google.com with SMTP id q14so39144631wrm.9 for ; Mon, 16 Sep 2019 07:42:30 -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=P3cM65404bjGz2MqZOyNYA1J6K0Tji+FY3F8UQivyng=; b=UfMJi/4j/flplu5w63u6IyQF35+YehZAki8Kywi+0OqaPFpnrPr+QQxILE/Jydcr/U zd5gHwQstSEoHfTlkhlLW9h01oAPOYPxsJKGzjosLKx/gie5M/eEXyLkSUOQDry0QpTk txEzjBhPEV5A/jAfcS340u67utOze3paKtrdyZJkGsT8aHCUgtAbIS4UnfJtuaIbOcyt i0L4Kn+dlz0QTgNDkrxxc7VavmH8g7cNnqo/yTt9bcuIlTAChWjVnfkoppp+KLbC52zj 2dvVgMlyQYPx+97IM9srcz4tjFmzA3arJWJPS3BtGUDsN1nwYtQMpLumv2wj4wEjJVPQ GHtA== 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=P3cM65404bjGz2MqZOyNYA1J6K0Tji+FY3F8UQivyng=; b=A2qE47Zo15WAREFVXnprmetJ0S/8dTVkJub32QkbT0iQyycPuQZZi7eZpxE/pK/Yk8 QaD5IX+bhx0HhV0BtebJvbqnfFn43j36WeaXA8SEuZo12i2czsJlFZzuyx6dSOjgUEtZ dFhb1CcdOvoEdz+LfLjyojpGcbuCYxzG645RihVv2FnFfYxWu6SpXYVBi/NxdC6VakWw fpP4wrfJYpiTsd7NqTe7bykwKtZM/445M1SbkiNM/jdR7LrBamGzEiZig43u20YYMlI7 6uStvp1O3j0yYmGx+K3GkSp51CIefp1Nhur0uvbCkSTvg+XBHS6EEVEmd8Ui8030y+A4 7ejw== X-Gm-Message-State: APjAAAXENrq0YemqNx8V97kkKLZKFgUNIBS9KO45Fto89632FQo73fvo tfsUpkPsKT/b1HUIERVjNTRJZXE9 X-Google-Smtp-Source: APXvYqwYvGXH1cR5CVHidYOct5HbuAb1F2mlEm4d7jFxmlzLNnqzr0rVrDvyVyLj5dtrgTVhQWhsdQ== X-Received: by 2002:a5d:4803:: with SMTP id l3mr77839wrq.301.1568644949231; Mon, 16 Sep 2019 07:42:29 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:56 +0200 Message-Id: <1568644929-9124-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PULL 16/29] hw/i386/pc: Extract e820 memory layout code 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Suggested-by: Samuel Ortiz Reviewed-by: Li Qiang Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-3-philmd@redhat.com> --- hw/i386/Makefile.objs | 2 +- hw/i386/e820_memory_layout.c | 59 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/e820_memory_layout.h | 42 ++++++++++++++++++++++++++++++ hw/i386/pc.c | 61 +------------------------------------------- include/hw/i386/pc.h | 11 -------- target/i386/kvm.c | 1 + 6 files changed, 104 insertions(+), 72 deletions(-) create mode 100644 hw/i386/e820_memory_layout.c create mode 100644 hw/i386/e820_memory_layout.h diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 5d9c9ef..d3374e0 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_KVM) += kvm/ -obj-y += multiboot.o +obj-y += e820_memory_layout.o multiboot.o obj-y += pc.o obj-$(CONFIG_I440FX) += pc_piix.o obj-$(CONFIG_Q35) += pc_q35.o diff --git a/hw/i386/e820_memory_layout.c b/hw/i386/e820_memory_layout.c new file mode 100644 index 0000000..bcf9eaf --- /dev/null +++ b/hw/i386/e820_memory_layout.c @@ -0,0 +1,59 @@ +/* + * QEMU BIOS e820 routines + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * SPDX-License-Identifier: MIT + */ + +#include "qemu/osdep.h" +#include "qemu/bswap.h" +#include "e820_memory_layout.h" + +static size_t e820_entries; +struct e820_table e820_reserve; +struct e820_entry *e820_table; + +int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) +{ + int index = le32_to_cpu(e820_reserve.count); + struct e820_entry *entry; + + if (type != E820_RAM) { + /* old FW_CFG_E820_TABLE entry -- reservations only */ + if (index >= E820_NR_ENTRIES) { + return -EBUSY; + } + entry = &e820_reserve.entry[index++]; + + entry->address = cpu_to_le64(address); + entry->length = cpu_to_le64(length); + entry->type = cpu_to_le32(type); + + e820_reserve.count = cpu_to_le32(index); + } + + /* new "etc/e820" file -- include ram too */ + e820_table = g_renew(struct e820_entry, e820_table, e820_entries + 1); + e820_table[e820_entries].address = cpu_to_le64(address); + e820_table[e820_entries].length = cpu_to_le64(length); + e820_table[e820_entries].type = cpu_to_le32(type); + e820_entries++; + + return e820_entries; +} + +int e820_get_num_entries(void) +{ + return e820_entries; +} + +bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) +{ + if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) { + *address = le64_to_cpu(e820_table[idx].address); + *length = le64_to_cpu(e820_table[idx].length); + return true; + } + return false; +} diff --git a/hw/i386/e820_memory_layout.h b/hw/i386/e820_memory_layout.h new file mode 100644 index 0000000..2a0ceb8 --- /dev/null +++ b/hw/i386/e820_memory_layout.h @@ -0,0 +1,42 @@ +/* + * QEMU BIOS e820 routines + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * SPDX-License-Identifier: MIT + */ + +#ifndef HW_I386_E820_H +#define HW_I386_E820_H + +/* e820 types */ +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 +#define E820_UNUSABLE 5 + +#define E820_NR_ENTRIES 16 + +struct e820_entry { + uint64_t address; + uint64_t length; + uint32_t type; +} QEMU_PACKED __attribute((__aligned__(4))); + +struct e820_table { + uint32_t count; + struct e820_entry entry[E820_NR_ENTRIES]; +} QEMU_PACKED __attribute((__aligned__(4))); + +extern struct e820_table e820_reserve; +extern struct e820_entry *e820_table; + +int e820_add_entry(uint64_t address, uint64_t length, uint32_t type); +int e820_get_num_entries(void); +bool e820_get_entry(int index, uint32_t type, + uint64_t *address, uint64_t *length); + + + +#endif diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 31e9c1f..81e5a59 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -87,6 +87,7 @@ #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" #include "config-devices.h" +#include "e820_memory_layout.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -98,22 +99,6 @@ #define DPRINTF(fmt, ...) #endif -#define E820_NR_ENTRIES 16 - -struct e820_entry { - uint64_t address; - uint64_t length; - uint32_t type; -} QEMU_PACKED __attribute((__aligned__(4))); - -struct e820_table { - uint32_t count; - struct e820_entry entry[E820_NR_ENTRIES]; -} QEMU_PACKED __attribute((__aligned__(4))); - -static struct e820_table e820_reserve; -static struct e820_entry *e820_table; -static unsigned e820_entries; struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; /* Physical Address of PVH entry point read from kernel ELF NOTE */ @@ -880,50 +865,6 @@ static void handle_a20_line_change(void *opaque, int irq, int level) x86_cpu_set_a20(cpu, level); } -int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) -{ - int index = le32_to_cpu(e820_reserve.count); - struct e820_entry *entry; - - if (type != E820_RAM) { - /* old FW_CFG_E820_TABLE entry -- reservations only */ - if (index >= E820_NR_ENTRIES) { - return -EBUSY; - } - entry = &e820_reserve.entry[index++]; - - entry->address = cpu_to_le64(address); - entry->length = cpu_to_le64(length); - entry->type = cpu_to_le32(type); - - e820_reserve.count = cpu_to_le32(index); - } - - /* new "etc/e820" file -- include ram too */ - e820_table = g_renew(struct e820_entry, e820_table, e820_entries + 1); - e820_table[e820_entries].address = cpu_to_le64(address); - e820_table[e820_entries].length = cpu_to_le64(length); - e820_table[e820_entries].type = cpu_to_le32(type); - e820_entries++; - - return e820_entries; -} - -int e820_get_num_entries(void) -{ - return e820_entries; -} - -bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) -{ - if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) { - *address = le64_to_cpu(e820_table[idx].address); - *length = le64_to_cpu(e820_table[idx].length); - return true; - } - return false; -} - /* Calculates initial APIC ID for a specific CPU index * * Currently we need to be able to calculate the APIC ID from the CPU index diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 19a8378..062feeb 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -291,17 +291,6 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory); void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry); -/* e820 types */ -#define E820_RAM 1 -#define E820_RESERVED 2 -#define E820_ACPI 3 -#define E820_NVS 4 -#define E820_UNUSABLE 5 - -int e820_add_entry(uint64_t, uint64_t, uint32_t); -int e820_get_num_entries(void); -bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); - extern GlobalProperty pc_compat_4_1[]; extern const size_t pc_compat_4_1_len; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 3435fc4..9206909 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -41,6 +41,7 @@ #include "hw/i386/apic-msidef.h" #include "hw/i386/intel_iommu.h" #include "hw/i386/x86-iommu.h" +#include "hw/i386/e820_memory_layout.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" From patchwork Mon Sep 16 14:41:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aDjFmcOM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9g95J62z9sPw for ; Tue, 17 Sep 2019 01:50:13 +1000 (AEST) Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tGU-0007ZF-UG for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:50:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53773) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD3-0006d8-Dq for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD2-0007WR-1W for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:33 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:34102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD1-0007WA-Nd for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:31 -0400 Received: by mail-wr1-x434.google.com with SMTP id a11so29423730wrx.1 for ; Mon, 16 Sep 2019 07:42: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=Clgbn8VC1npnngFnwGDRl9+7yey7IgZd01g1UbgiZRo=; b=aDjFmcOMH5mA7YsMiJ3BFlA9SMqxaVialQRmvoWCb/BgOe+uT8H52C++ZFVrbnJKgg wdHdGutf/hlHeHVx5/ZX+0TFIrtcZjMWNyjPJbqSIOL9VI1H6jopvuadUGjMVZNOpYcw BAp/izoBIMLN/gWsifaNk+6ArreO8c9yR8x+dAWrellpRYqsze4zEza8rBVHNBZG5w0t IlYlZH1hUIn7UCbisXvE1vq0xeqC4sk1iVM5tvlvx5jC7RsU6AIdHy3V4EtUwYLK9ZlU wT74mGJyK4EM3TRMrSroFgGNrxVpQ0otUoT4RJJmc0wal4cw7AzaCYkpe2G0WDA7FC0l ht2w== 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=Clgbn8VC1npnngFnwGDRl9+7yey7IgZd01g1UbgiZRo=; b=Hy8v8ukG2tCys2lOJC9nUQQE+PQk+SwbM1r3URsLhl+AflG5LpxWm0ihODJ6a8NQui IZIINjl8f4QDUByoL/VZv0tna11ovVk9Td5E8zgebWvHwBx+uluHBHtk6w22YhoW6Qsr P5O++0wwyjT25gXkFCQkqze5QyL1j6IrqVIb9OpGntnjz0ouZpxXZQqbVndDUrsgpwK6 NR/lBy0V+FYsYCS+nWhHu+3KABWiXFJoJJbthGgIXNulMGJWPk2RKrSe+Ad0FOHo8YGv Fx4OyeOXDChIL6FwMXZZUNsC/YHfBr4c18CC3XBqM6mISPasbpf9eLheuaCqzKZwxKv3 BjAA== X-Gm-Message-State: APjAAAV4SLqrAU28TZ5F1l8BToYaEZRePjTp69KQgNG6zAGTvutrVRwt UQ6xWs7V9rqnvvRVNd4/aCOOZ7E4 X-Google-Smtp-Source: APXvYqywElG9yC3S3GoKxj3QMAgxr7mwz425mWj6dg96HevMBsy5VrqFN95i+lS08Vy4yMSwsYrgqg== X-Received: by 2002:adf:df91:: with SMTP id z17mr126630wrl.116.1568644950397; Mon, 16 Sep 2019 07:42:30 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:57 +0200 Message-Id: <1568644929-9124-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 Subject: [Qemu-devel] [PULL 17/29] hw/i386/pc: Use address_space_memory in place 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The address_space_memory variable is used once. Use it in place and remove the argument. Suggested-by: Samuel Ortiz Reviewed-by: Li Qiang Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-4-philmd@redhat.com> --- hw/i386/pc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 81e5a59..dd5ec2e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -936,7 +936,7 @@ static void pc_build_smbios(PCMachineState *pcms) } } -static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms) +static FWCfgState *bochs_bios_init(PCMachineState *pcms) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; @@ -946,7 +946,8 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms) MachineState *ms = MACHINE(pcms); int nb_numa_nodes = ms->numa_state->num_nodes; - fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, as); + fw_cfg = 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, pcms->boot_cpus); /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: @@ -1868,7 +1869,7 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = bochs_bios_init(&address_space_memory, pcms); + fw_cfg = bochs_bios_init(pcms); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eWmLOeeb"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9j63p0Fz9sPw for ; Tue, 17 Sep 2019 01:51:54 +1000 (AEST) Received: from localhost ([::1]:36226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tI7-0001UZ-Qk for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:51:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53790) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD5-0006e7-4H for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD3-0007Ws-2a for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:34 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:39718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD2-0007WW-Pt for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:32 -0400 Received: by mail-wr1-x42e.google.com with SMTP id r3so9038646wrj.6 for ; Mon, 16 Sep 2019 07:42: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=2ZFt5Ej0MDKjJMSatLtGLf2qPb/bGGxrP7DW7hhkcec=; b=eWmLOeebRHotKX7qHJQc6pC3pkJ8m9mrsJtYKPGgyoaRSHR6QKdvQMIEulYtFW7BdL aovw2Vp1UskS4xtFZyrIHthxw9aQF6/Q07LP2UX55kxqZ6LJcQkvN65UDmCVGOV5zIrc BZ3ST66AJolhI1CerW4obu+G/q26FVgIs68pb8FmbSSPdQg3yo+hCUAbgvrqxUwV9HsA 9dxSCfaSLR4mwyU9nvq8q1B4FAl+XsZqiw3pg6OOZUBsK7Th38UgSRWitc/uEQLLW2jo 7F6x2S7oGNsvrFq5nZlfQuaRZL3BEKyBXDJIDqCxUFcnm9XydPIBcmaVJXrAVsiejvL8 w6Xw== 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=2ZFt5Ej0MDKjJMSatLtGLf2qPb/bGGxrP7DW7hhkcec=; b=jqkyfF/KYbYKFVOvwc90wR67pecsnsYMfDEkVriatTA9OvxrIxjRaHzcTht/v5lJk2 ref7D4cGu0KVX38lKvuPQJl1xstu9eO8/YcmgV2trjPJMZf95iy9pHDrGfIuH+4wILqo 9xwfpyV4T8yIMSIDw6MdQdJCGk3b47VqPvDbWH/7UrM1amqkcYh0q4E5dEmlpOdm5yOa EBAEA2UfU2trpU9hxPSkeaA4/cpc7RxDzaujSPeAiaUeeLfGe3CTVJqfpmXtwxK+MEgU 3fW+nJzvd9bRZ/bFsfnlBz9lM02tzfbv8vN9ZG112m4ksybsJh76nYpBdh5oQz8esXU7 e9fw== X-Gm-Message-State: APjAAAUpveB8w/xoL7T5Di8l6xdflcM2fkm2FwnJYVSk3LVkpc1picjH q4K8WkJCYohv/3miaX5cRTWSnMNI X-Google-Smtp-Source: APXvYqwnCDUKGboUj/aOlkNWN4zrDVkidLlRvbGwxtqbjy/kq8HoT11aWCxn+6nk5FucB/r9dw1LRQ== X-Received: by 2002:a05:6000:188:: with SMTP id p8mr121525wrx.220.1568644951525; Mon, 16 Sep 2019 07:42:31 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:58 +0200 Message-Id: <1568644929-9124-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PULL 18/29] hw/i386/pc: Rename bochs_bios_init as more generic fw_cfg_arch_create 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The bochs_bios_init() function is not restricted to the Bochs BIOS and is useful to other BIOS. Since it is not specific to the PC machine, and can be reused by other machines of the X86 architecture, rename it as fw_cfg_arch_create(). Suggested-by: Samuel Ortiz Reviewed-by: Li Qiang Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-5-philmd@redhat.com> --- hw/i386/pc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index dd5ec2e..b15af77 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -936,7 +936,7 @@ static void pc_build_smbios(PCMachineState *pcms) } } -static FWCfgState *bochs_bios_init(PCMachineState *pcms) +static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; @@ -1614,7 +1614,7 @@ void pc_cpus_init(PCMachineState *pcms) * 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 bochs_bios_init(). + * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_create(). */ pcms->apic_id_limit = x86_cpu_apic_id_from_index(pcms, ms->smp.max_cpus - 1) + 1; @@ -1869,7 +1869,7 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = bochs_bios_init(pcms); + fw_cfg = fw_cfg_arch_create(pcms); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:41:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mWPXKb9U"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9n16YQ5z9sNf for ; Tue, 17 Sep 2019 01:55:17 +1000 (AEST) Received: from localhost ([::1]:36306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tLP-0005UO-1e for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:55:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53812) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD6-0006ev-4x for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD4-0007XR-KV for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:35 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:33079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD3-0007Wq-V2 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:34 -0400 Received: by mail-wr1-x42a.google.com with SMTP id b9so5596908wrs.0 for ; Mon, 16 Sep 2019 07:42: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=jOoruMaTeCNDoafHm9yLjtEQ2dgmSuxRKdw4PApSxEU=; b=mWPXKb9UZOsYDYsQLg4seRhbOR4KHg9FYhcDN++F6fBtqgEIZxPLIq+7fGSABD0I+D 7bgLi5b2TvWx1h351IovjH35KeN7GdQiKrMs/KwqUfWymlj3YEoNvPhDCJ4yxyllXESa kmpOzjMmiiDO//pLHrn8CuRJ6p1i8jSs3rX4GJgY4GfTCaKNFkfXKG1r7SyB/lT/QzBn TkBel88Uj3fe+6q00bpryCsaKsvhgMa21KkjWMYwzn9nPg2u5Jrk43YPhZoQNMNCtVeg jFueUPlV7RjOLxXlmrpbwZQphz1Zek796pEiTWafdF3Zz0zoe1VXJpdXl6Umh/UFqZS7 zBzA== 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=jOoruMaTeCNDoafHm9yLjtEQ2dgmSuxRKdw4PApSxEU=; b=hZpS9Ywv9Y85pQIPzrrYADZMctFykxLk+iSnOVFlYeDRsjSjbIj6Mqv/R6UnD8zeFJ cIdEqzq9sZzME0dHc6Jra9TaSpmU70MBgqaFMfiKX/BCLSg1yhc8qNYoN7RtfhLCGnW8 s6Ga7uhEJTO1n0IRdrW+LyHOm06xmYtQS/gPwcV4cf4S5kYsS99nIF1azlnBza+x079c Lw+WkL/9zyA7/AMS91RdeT5GpHTYA3XtIkcOoDyHwr+iDAnhxxFCpMtmMl8xjoSQQ3Cx whRez1Wq1Il4vayEm1jotOZs9DtyGefaIPFTMcVhd5q4DC+SINjkTVXzrabEfp4n6tFq 9f+Q== X-Gm-Message-State: APjAAAXQ2/3wLXrbCV+pQ02A8vY3FpyLdVxSNrhHiborlageJ6u3Zg0l 7w0Su4OZ5JsaKzDrmpoVdM7RtjPf X-Google-Smtp-Source: APXvYqwy9Ht7NTtK6Np+Pla70MO4cpb1omyo6b1TBXeWeSSQpWrmaRBJv0Hhi2ZICPMzmhfp6rbJVA== X-Received: by 2002:adf:d848:: with SMTP id k8mr113707wrl.254.1568644952411; Mon, 16 Sep 2019 07:42:32 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:59 +0200 Message-Id: <1568644929-9124-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 19/29] hw/i386/pc: Pass the boot_cpus value by argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The boot_cpus is used once. Pass it by argument, this will allow us to remove the PCMachineState argument later. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-6-philmd@redhat.com> --- hw/i386/pc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b15af77..dc2ae6d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -936,7 +936,8 @@ static void pc_build_smbios(PCMachineState *pcms) } } -static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms) +static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, + uint16_t boot_cpus) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; @@ -948,7 +949,7 @@ static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms) fw_cfg = 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, pcms->boot_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, boot_cpus); /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: * @@ -1869,7 +1870,7 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = fw_cfg_arch_create(pcms); + fw_cfg = fw_cfg_arch_create(pcms, pcms->boot_cpus); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:42:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M3rAubFD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8sm4ZPfz9sPq for ; Tue, 17 Sep 2019 01:14:20 +1000 (AEST) Received: from localhost ([::1]:35766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9shm-0004uf-1Z for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:14:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53830) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD8-0006fR-3b for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD5-0007Xm-CU for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:37 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:54517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD5-0007XC-28 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:35 -0400 Received: by mail-wm1-x333.google.com with SMTP id p7so60499wmp.4 for ; Mon, 16 Sep 2019 07:42: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=36OSTNyRUV4b/XNoOmWOxSWxIOvrUZW6VSBB/hBkj2A=; b=M3rAubFDI/++9ySeVt2ZAUzAsMAL5TKSLbUuhWfRVVPl6NJ74EqrQFkQFZdmxQU8Cj KZ+nHHysyoP2sIT/u15ohpfUNInSVV7tGTMFDcmNpvjhsGF0V/ACRkkaZy36lAfX96qA EkUtYQEm/srjrP59vGU3oMSUbugFyG0jGYzazOYerIOB+Prj2loj9bhf9nrO7hekixIx L9mKGd18Jiq1WjNP1OtN5D9fIlFY8bqEpF+OxJnSlKxjPF3LhMCmKM++k2R2cFXkXakf xDhGvZ4xu7su21m5tbpfKPRwzs3Al+Ko3MeTl+i0FvkSVGtIQyxwYZOZEYy5Iw/d+Xzg a33A== 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=36OSTNyRUV4b/XNoOmWOxSWxIOvrUZW6VSBB/hBkj2A=; b=fkHUfeZQOyRurZRaNID5ukXDc51HrWtXBBfPRbBea5/bnwFwyLWLBz6XJGlhMrHrNZ fEl7oZKzS/UA407+gQ8LLSOgiKuxFLMEJ4GW0tRi7tItexDzdPKzM/zpwQzJdlnHnFkr 4lvwUOeCN+LrJblE5N3PZN29JB2XuhyU9XVKZZBIhUd4YlZyI7obZkLEgms7/TIJXujl 3LeYxgmSZ+QjVG0EiHObRK+oKSD2nSekDSklZ2qpFGEAduJ/yxJS5qFVkWe490oSyzGx pPZ9YK+o3kyvUrNEtHZzeP4RWOpo2s+Lcq8fHg3dDBy7JBKhbwhJbWCitR/Lsz058g+U 9RCw== X-Gm-Message-State: APjAAAXESvsMpEt7KouszKTV8omgfDWvnb4+0GKk+sAvmMucCNUQzzzj ZqUOMMcs5cRwkpH8I5HxdnG9YN2s X-Google-Smtp-Source: APXvYqwjI+TZOsg90wzejZQpQ3EWrzz3d/Q+dflbV0YleaElngDBYZsZIOc+kHeDIMYRobbSa/NtxA== X-Received: by 2002:a1c:c789:: with SMTP id x131mr79907wmf.20.1568644953459; Mon, 16 Sep 2019 07:42:33 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:00 +0200 Message-Id: <1568644929-9124-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL 20/29] hw/i386/pc: Pass the apic_id_limit value by argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Pass the apic_id_limit value by argument, this will allow us to remove the PCMachineState argument later. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-7-philmd@redhat.com> --- hw/i386/pc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index dc2ae6d..c0e9d83 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -937,7 +937,8 @@ static void pc_build_smbios(PCMachineState *pcms) } static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, - uint16_t boot_cpus) + uint16_t boot_cpus, + uint16_t apic_id_limit) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; @@ -1870,7 +1871,7 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = fw_cfg_arch_create(pcms, pcms->boot_cpus); + fw_cfg = fw_cfg_arch_create(pcms, pcms->boot_cpus, pcms->apic_id_limit); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sf7JM9PU"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9513Gd2z9sPn for ; Tue, 17 Sep 2019 01:24:05 +1000 (AEST) Received: from localhost ([::1]:35836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9srC-0004Nk-En for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:24:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53828) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sD8-0006fM-1y for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sD6-0007YE-3N for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:37 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:53562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD5-0007Xc-NT for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:36 -0400 Received: by mail-wm1-x329.google.com with SMTP id i16so67873wmd.3 for ; Mon, 16 Sep 2019 07:42:35 -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=D4qmsiElKCvJ7YmXi8gkY9T9VEadqIQ5nlKcIn2oRS4=; b=sf7JM9PUZZ1w+Ggbi4daGN6FkFUNmKLHiQx/7jRT//W+PlamOjDQTjmB6r9OGGgajH M2ux7xQ6qqc8oL3H1qnKUeFA0CiqmqsIk0nsOGrfO+qWpAt6MvPqmbChZLOwq7rNG1dP k2ehW55oQAN6aYoGhJsKhuude9dwNxZA+mEs+vqmAHd1DBBzqRvwbQtbdrhepM2Cmldz B04qFcIyD33wxSqyGCFv7o3fiy2Gpfgqp85SbKpdexHYnyvvWnoM/ovqioUivMSg/0rv l3Bz1lAHgcj0qaYdiuNgMu3P/pDd6bNwdaNBikoYqnw9MnxEEWoTIXImWzML3YBD9FRR lSrA== 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=D4qmsiElKCvJ7YmXi8gkY9T9VEadqIQ5nlKcIn2oRS4=; b=NYIyjDtmwXs9waFW6aDFHO8U1dDsdM3riUFZoFmgB+XWjWvfrEhMwyOTb3hK/b+Ol6 aKbiiif6XaNpvs7G4tL7g1Fg0+Z7tKWG+zTBx2osRQlwRLDxv7AlT9wMYd8MjXiB/r5P sa3Y304EpVkX9EtbpYldOhygvf3+HSgxJLmBoPGTkjTnksqlNQDcYtVUxpAiu5LIu4Vy ffIVhHXdjqigqnhSTGZlueUAKkBMVTtUsY94JKTPPLEGUJS3D7cwAWkn1/1xTBcIkvFr 59t+3cf8emUsfoznwc6+135+0MLpZN13XltfTmVcQW4QhF0NZDh9BYkodzGSUB1vI8sr DzmA== X-Gm-Message-State: APjAAAU4vu5WlruksrQ7DXExQqu//YJWOLve1otxOyNFAUKFUj2JM5D1 Ra+WG1PBhPvdq9s8HMVVnwXHbCHe X-Google-Smtp-Source: APXvYqx6Qv/0rlijM6rtXNuBgAqCYagOYVjLNHEOnKVUsYA88YIn2eQSi6hiJcJpld6OIryyttpTqg== X-Received: by 2002:a1c:c104:: with SMTP id r4mr74546wmf.64.1568644954351; Mon, 16 Sep 2019 07:42:34 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:01 +0200 Message-Id: <1568644929-9124-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 21/29] hw/i386/pc: Pass the CPUArchIdList array by argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Pass the CPUArchIdList array by argument, this will allow us to remove the PCMachineState argument later. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-8-philmd@redhat.com> --- hw/i386/pc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c0e9d83..5b3f615 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -937,14 +937,13 @@ static void pc_build_smbios(PCMachineState *pcms) } static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, + const CPUArchIdList *cpus, uint16_t boot_cpus, uint16_t apic_id_limit) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; int i; - const CPUArchIdList *cpus; - MachineClass *mc = MACHINE_GET_CLASS(pcms); MachineState *ms = MACHINE(pcms); int nb_numa_nodes = ms->numa_state->num_nodes; @@ -964,7 +963,7 @@ static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, * So for compatibility reasons with old BIOSes we are stuck with * "etc/max-cpus" actually being apic_id_limit */ - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)pcms->apic_id_limit); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, apic_id_limit); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, acpi_tables, acpi_tables_len); @@ -980,20 +979,19 @@ static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, * of nodes, one word for each VCPU->node and one word for each node to * hold the amount of memory. */ - numa_fw_cfg = g_new0(uint64_t, 1 + pcms->apic_id_limit + nb_numa_nodes); + numa_fw_cfg = g_new0(uint64_t, 1 + apic_id_limit + nb_numa_nodes); numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); - cpus = mc->possible_cpu_arch_ids(MACHINE(pcms)); for (i = 0; i < cpus->len; i++) { unsigned int apic_id = cpus->cpus[i].arch_id; - assert(apic_id < pcms->apic_id_limit); + assert(apic_id < apic_id_limit); numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id); } for (i = 0; i < nb_numa_nodes; i++) { - numa_fw_cfg[pcms->apic_id_limit + 1 + i] = + numa_fw_cfg[apic_id_limit + 1 + i] = cpu_to_le64(ms->numa_state->nodes[i].node_mem); } fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg, - (1 + pcms->apic_id_limit + nb_numa_nodes) * + (1 + apic_id_limit + nb_numa_nodes) * sizeof(*numa_fw_cfg)); return fw_cfg; @@ -1775,6 +1773,7 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion *ram_below_4g, *ram_above_4g; FWCfgState *fw_cfg; MachineState *machine = MACHINE(pcms); + MachineClass *mc = MACHINE_GET_CLASS(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); assert(machine->ram_size == pcms->below_4g_mem_size + @@ -1808,7 +1807,6 @@ void pc_memory_init(PCMachineState *pcms, if (!pcmc->has_reserved_memory && (machine->ram_slots || (machine->maxram_size > machine->ram_size))) { - MachineClass *mc = MACHINE_GET_CLASS(machine); error_report("\"-memory 'slots|maxmem'\" is not supported by: %s", mc->name); @@ -1871,7 +1869,8 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = fw_cfg_arch_create(pcms, pcms->boot_cpus, pcms->apic_id_limit); + fw_cfg = fw_cfg_arch_create(pcms, mc->possible_cpu_arch_ids(machine), + pcms->boot_cpus, pcms->apic_id_limit); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BbUlwGO+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X98X2VjYz9sPn for ; Tue, 17 Sep 2019 01:27:07 +1000 (AEST) Received: from localhost ([::1]:35876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9su9-0000DB-CA for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:27:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53855) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDC-0006gY-EI for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDA-0007ZP-1l for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:41 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:54519) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD7-0007YJ-V8 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:38 -0400 Received: by mail-wm1-x335.google.com with SMTP id p7so60637wmp.4 for ; Mon, 16 Sep 2019 07:42:36 -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=KiFCZUVAPnnWNqhg3WDsyPWMV8xe1NmN4cPuEbcJmC4=; b=BbUlwGO+gso8YZDbG4T+MReP3mREKgRl1mYeC45zamXl+voad8SeFVwmMlZDYQeQRF 8tRt5iW+6pZOYAjs7wXyNmlzUwpmm3XgSiaLBeircu9bzQsVQc37ogAXfaOdZalYFhzb +e80/3a3AiIJkAePRLLN6sCZ64pc95ENY7b0ZLkdNX5ullcDwVBHiNsLln+LLaM63Uq7 YlXZb77GIHFCGbU8x1fHgkC7lwqEfgwdpJwzzlz3Gbn+QUiN8aGINU3pkxMA3jEfnOUD uyYGMnRHNXPKv2hV1Q9pnHTn3pfMjW3ewUaH6VBYU5xNNYsA9fUJdk/mWnB0srWvBxKx R8Kw== 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=KiFCZUVAPnnWNqhg3WDsyPWMV8xe1NmN4cPuEbcJmC4=; b=XwwgoGbf1Vdoa2ESMIe74d+Apru3zjPWoXN0FpipE2JQiwEbHftAUiUIEIcgxzqZrz wTfms09sKdURWvN9GtGmNjOOBqQm7LOiJ4e7a1aD1sW2YTHchKQKakr1IrZBHwgB5V5K wzxBqM2YVCjzRMmVi3VmEQYRXKZ9fYL5nCCEVIoUh44zd/hOuNJEyu6et5NT6YZReg1d Yko4pyo4TZT6oVY3zdydKpp50YNo2o9x1zxpYoBpCHrUSYljNEu4Wu5knCuzzM2KgFcy iNfpYLlTz3JJVv/KGVlcPZ0Ix43oyRpoeh4ynvCGA6FHqVgJHe8nNpSSA/j6Ig20iiyX PMbg== X-Gm-Message-State: APjAAAV0Ro8VfjmyaHtO3iXlyLGWS1iuyxl2UDLBi/5h96ioHlRb1q6d 9HIQW+ONnJe4ERjmjZalNMXMP1u3 X-Google-Smtp-Source: APXvYqwpFtieHmWoMHoSEI4NxDvLoh0fZ7yPel91NweI9mQBSi8HUzJUxwfChB3t2DMfZDUJRqAfQA== X-Received: by 2002:a1c:2302:: with SMTP id j2mr47813wmj.174.1568644955495; Mon, 16 Sep 2019 07:42:35 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:02 +0200 Message-Id: <1568644929-9124-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-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 Subject: [Qemu-devel] [PULL 22/29] hw/i386/pc: Replace PCMachineState argument with MachineState in fw_cfg_arch_create 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In the previous commit we removed the last access to PCMachineState. Replace it with a generic MachineState argument and use it to retrieve the CPUArchIdList. Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5b3f615..8d2e600 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -936,15 +936,15 @@ static void pc_build_smbios(PCMachineState *pcms) } } -static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms, - const CPUArchIdList *cpus, +static FWCfgState *fw_cfg_arch_create(MachineState *ms, uint16_t boot_cpus, uint16_t apic_id_limit) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; int i; - MachineState *ms = MACHINE(pcms); + MachineClass *mc = MACHINE_GET_CLASS(ms); + const CPUArchIdList *cpus = mc->possible_cpu_arch_ids(ms); int nb_numa_nodes = ms->numa_state->num_nodes; fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, @@ -1869,7 +1869,7 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); - fw_cfg = fw_cfg_arch_create(pcms, mc->possible_cpu_arch_ids(machine), + fw_cfg = fw_cfg_arch_create(machine, pcms->boot_cpus, pcms->apic_id_limit); rom_set_fw(fw_cfg); From patchwork Mon Sep 16 14:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FStat188"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9st2Xw4z9sNf for ; Tue, 17 Sep 2019 01:59:30 +1000 (AEST) Received: from localhost ([::1]:36338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tPT-0001DH-Me for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:59:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDG-0006hR-EH for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDB-0007Zr-Uk for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:45 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:38539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sD8-0007Ya-7c for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:39 -0400 Received: by mail-wm1-x332.google.com with SMTP id o184so76744wme.3 for ; Mon, 16 Sep 2019 07:42:37 -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=1loFgfoo8O+0OkFX8to4l4qCch6xvKAVs5sNReYGYME=; b=FStat188H8P1fmPqcsWuTamTvVXdP4cUgAU70kzo/CeXNHNVNFBawj7G8bkbYQmeEH +P01npwxW7Fa/UpD82h6sKKHVDcRgWwPZ7bW+2IbCChbZLhsnv49ouVB3dKzO+VDha3t zKrcsjZUYMAUv+i4Z4rE9PlSk1JVZJ4sZAQTHifFMOYZTjlxDMlOctfE7Tj+wwLgqcvZ oTo6zP31WEAiaJkjz48Ccdmvt9qj7bM/KSb7sn0Z/UpCC8Ng6KMHU3wCcqlE7/sQiyFp Y1ctlSpMg2w1xWbF6aSlfkJxdPGASWkwcZzFU4mPLy7kaZLtvjXjcSj9msD6EsZt8iOs SAtQ== 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=1loFgfoo8O+0OkFX8to4l4qCch6xvKAVs5sNReYGYME=; b=kNLWGOWzf7QOe0fJpsangAhNwQPk90aImgvMPph2voXdddGqnlMGJPczPVfnQZ626D SCsbemIkEk538J0YnCFX2QISf+2af8xMDVaHADe1PqD/ComiCJiRi+37BKdjXdcFDqQa j4HZAWTwl3u43EqN5gwk9+MDeERw3/FNo32+YQIIMhMx5ZJRASxBz2EMHarZD9d98tkt 8kULAj0wXidRuC3quzKM02R8R2PrWCYB1XUcFYndJXHiJqHnDB7bod8Z0P9vJft3BpDg DqIDqUoNwYr6PPHKMcJcuTpApyyqRkXXM0qcDlKs1be459pjVVlQ9a5c27BYuYrdqb7X udiw== X-Gm-Message-State: APjAAAX6puMXFUKKE6occA4Wknsf1QTJNEabm767zwDsV/aiuC9+AuZm N51rTderClVxIqX87bNwadKm2EdX X-Google-Smtp-Source: APXvYqznLdHQCw9K8x7FP6jvb3zHmH/KpELDsX4qsgmgJHgwZhUQAeh7enumjNz8SBByXvcyxJ+rWA== X-Received: by 2002:a7b:c391:: with SMTP id s17mr67373wmj.94.1568644956598; Mon, 16 Sep 2019 07:42:36 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:03 +0200 Message-Id: <1568644929-9124-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 23/29] hw/i386/pc: Let pc_build_smbios() take a FWCfgState argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Pass the FWCfgState object by argument, this will allow us to remove the PCMachineState argument later. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-10-philmd@redhat.com> --- hw/i386/pc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8d2e600..612d676 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -894,7 +894,7 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, } } -static void pc_build_smbios(PCMachineState *pcms) +static void pc_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg) { uint8_t *smbios_tables, *smbios_anchor; size_t smbios_tables_len, smbios_anchor_len; @@ -908,7 +908,7 @@ static void pc_build_smbios(PCMachineState *pcms) smbios_tables = smbios_get_table_legacy(ms, &smbios_tables_len); if (smbios_tables) { - fw_cfg_add_bytes(pcms->fw_cfg, FW_CFG_SMBIOS_ENTRIES, + fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); } @@ -929,9 +929,9 @@ static void pc_build_smbios(PCMachineState *pcms) g_free(mem_array); if (smbios_anchor) { - fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-tables", + fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables", smbios_tables, smbios_tables_len); - fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-anchor", + fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor", smbios_anchor, smbios_anchor_len); } } @@ -1695,7 +1695,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { - pc_build_smbios(pcms); + pc_build_smbios(pcms, pcms->fw_cfg); pc_build_feature_control_file(pcms); /* 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); From patchwork Mon Sep 16 14:42:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qr5cUvRa"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9qC22Phz9sNf for ; Tue, 17 Sep 2019 01:57:11 +1000 (AEST) Received: from localhost ([::1]:36324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tND-0007JN-Js for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:57:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53901) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDI-0006hs-Ah for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDG-0007av-8c for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDA-0007Yk-0b for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:42 -0400 Received: by mail-wr1-x441.google.com with SMTP id l3so16457524wru.7 for ; Mon, 16 Sep 2019 07:42:38 -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=k6PPn4Z/g3X9dRln047WPkkVlkbax9eyN7khSHdwCWQ=; b=qr5cUvRaDoKcm3sIix8djNM03JLDvHvrhTiY5UUdPyPGAAFysct2KR0SSan11eAjaI SECPiZz44c8KqH6J2xgU77Kqnr2neMpTIF1iNyA+PgkmdYVmstHR9ktmmZQDeV7joTPB lc77VFY56SpMnGx0Acup3W3Iz1ubSSZOQNXrMd6xTzhki/d/1qt8b+jcsFPciocZbJFK I0I60dDQa2Z8XndScwuGlQHTzCRvD7lTCVkuHOMKPKya2rJqRK6OvLf/UAhRDFzfOXx2 KdNZX9ngIxAbwpId/gZvCm7BjivCPoMLMgdPQygrR6VK59NGeClgzXDCOD5Fz4Y/tdZd 2Pmg== 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=k6PPn4Z/g3X9dRln047WPkkVlkbax9eyN7khSHdwCWQ=; b=E9nr3ED5qnie4CupXIT+5kHpjYP8vg5upI8fIz7XAMIaV5hzLA7dMjOlQg6uEOGif9 WlkO7IdqvHybsXnIHSvjxmHoztUeD5vizk1h/LF9Nl/gm9dBj9nDqWh1yTNL6fNqjBYO JN+hAeqct8yC0PFzpBjb4vOJ+C8+lYepXxIxk9aHdjHXXExt06kRKQ9nKdWeRGPYq1OQ GjAyrVo37pO+Zhhz3U3NHT9oschaYxKD0yjwEqCLQwzSFNXJ0DVm9tbko2nHN7nkewks yhhXU0CSl0QUbQmi6qc4RqHoARDyhQzc1QeSOF4fnW2symTzuZXjI+Ssb8yDvVy9+tQZ jLsw== X-Gm-Message-State: APjAAAWI7OscwXnwksA2SUDKPBpkfJ0EPTsU8giRy1F4xQwBoOwqy15J 6Tj30L529T9QK+YUGkFhYMcTfcA2 X-Google-Smtp-Source: APXvYqwE6g+Sdn7KASl5yFlmOKPBHWVTqeWe6XD42f7dFltiGXcBHhDLw+ybGY2XM3taHrcFCJ3mNg== X-Received: by 2002:adf:dc91:: with SMTP id r17mr143728wrj.22.1568644957405; Mon, 16 Sep 2019 07:42:37 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:04 +0200 Message-Id: <1568644929-9124-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 24/29] hw/i386/pc: Let pc_build_smbios() take a generic MachineState argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Let the pc_build_smbios() function take a generic MachineState argument. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-11-philmd@redhat.com> --- hw/i386/pc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 612d676..14ad611 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -894,13 +894,12 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, } } -static void pc_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg) +static void pc_build_smbios(MachineState *ms, FWCfgState *fw_cfg) { uint8_t *smbios_tables, *smbios_anchor; size_t smbios_tables_len, smbios_anchor_len; struct smbios_phys_mem_area *mem_array; unsigned i, array_count; - MachineState *ms = MACHINE(pcms); X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); /* tell smbios about cpuid version and features */ @@ -1695,7 +1694,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { - pc_build_smbios(pcms, pcms->fw_cfg); + pc_build_smbios(MACHINE(pcms), pcms->fw_cfg); pc_build_feature_control_file(pcms); /* 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); From patchwork Mon Sep 16 14:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TN+br5if"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9kf69Mvz9sNf for ; Tue, 17 Sep 2019 01:53:14 +1000 (AEST) Received: from localhost ([::1]:36258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tJP-0003Fr-V3 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:53:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53878) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDG-0006hS-EO for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDC-0007a9-IS for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:45 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:53572) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDA-0007Z1-1O for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:42 -0400 Received: by mail-wm1-x333.google.com with SMTP id i16so68168wmd.3 for ; Mon, 16 Sep 2019 07:42:39 -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=YSviaidB+9hmgagbX135i0HDFBWVdstIEmKCyx1ApvY=; b=TN+br5ifMyhqmGZSBEjFhLwaSpiY+Dw9CJyIa2K0yzjQ1c63nUSgNPdY7rN7pCa0ES GYK0f/F7WxASqMIA2p7Azwt72sRXq62qkmDI+mA2NqbNNR4Ft8jBTgUAAj3NjH1zdNy9 pYPt/j7+6VV0kcXi8+mfyeoWdYu6Wf3DbVLU2m29CP7I/oxc+hluPA2qYuPjEKdmF1r3 dFkt0XZCdsehaNvx3WNWDs3gKv3bcfj1l6UeAjbvXbnNj5ACyP07ujd4Q4rnAEYxsWTL sSfn6ZhPLcN00UyTbJfjgvwHlViSj13JL/5JYRMxgqmqcioRx782aHj28MHLMaTfEk3W mYpQ== 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=YSviaidB+9hmgagbX135i0HDFBWVdstIEmKCyx1ApvY=; b=ouGmPpdlZAwJwQhqTdcMocOPpaYzDykoJ5AfijuX+0eQfetaQVOuoOW3Ubd7RMawaV HxA1LUsfvE0PQTpNj2JK6TY7RWeT9HkWi+nYvvK+VRF7Q+UqWnwWvioyrLXtVrv8QzYA 3fNTl3fQwd4YSuRbfz7En9ZaeOsip0+xS97RaRWcVuhjhz//M4JBznSpCZpwIkO8sbwX gFEDaW/BJnwbz9+s08OemXHReOdQ19B0TEaX/eVPsbsbOt5YSUADlWwOYjFczdlnXy4h L9uqPEZWGyBgrhrQHFLqQnXVUHrS0/a3d6HRMBCWywa4wpA4wheExaJqAUGZ0+DdWnrY oxgA== X-Gm-Message-State: APjAAAXuVI5a4aCjgczxAdIsBFLfh8bSEO05KDATS26ih4bdtXtIqVM6 5s1VlTk+Dcb5ks9Dk/r5jxnA+jFF X-Google-Smtp-Source: APXvYqwhpCo+VEgjc2M/Ea6j9c9p+mHF4AADKdUvxCHIdfMbLQ8wd7YIht3+5h8P1pBrUNM2sHr1eQ== X-Received: by 2002:a1c:1bcf:: with SMTP id b198mr84536wmb.0.1568644958395; Mon, 16 Sep 2019 07:42:38 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:05 +0200 Message-Id: <1568644929-9124-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL 25/29] hw/i386/pc: Rename pc_build_smbios() as generic fw_cfg_build_smbios() 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Now that the pc_build_smbios() function has been refactored to not depend of PC specific types, rename it to a more generic name. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-12-philmd@redhat.com> --- hw/i386/pc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 14ad611..8f611cb 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -894,7 +894,7 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, } } -static void pc_build_smbios(MachineState *ms, FWCfgState *fw_cfg) +static void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg) { uint8_t *smbios_tables, *smbios_anchor; size_t smbios_tables_len, smbios_anchor_len; @@ -1694,7 +1694,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { - pc_build_smbios(MACHINE(pcms), pcms->fw_cfg); + fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg); pc_build_feature_control_file(pcms); /* 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); From patchwork Mon Sep 16 14:42:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vOq8cJ1+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X8zn0b67z9sPq for ; Tue, 17 Sep 2019 01:19:33 +1000 (AEST) Received: from localhost ([::1]:35808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9smo-0000Ke-6A for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53902) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDI-0006hu-Ac for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDG-0007b0-8K for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:40405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDC-0007ZG-3M for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:42 -0400 Received: by mail-wm1-x330.google.com with SMTP id b24so61672wmj.5 for ; Mon, 16 Sep 2019 07:42:40 -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=TOBUM8vB9k+Xxdjqza7KhK358ltTbzzQWCOfZA+EL9g=; b=vOq8cJ1+/vvNyrqblKpU0CsxLBsbHix4FR2atiu4osWKWIjYj4I+CNs1lPyMmETDyo YiCuxzYQc1jY3KW/d17JD6kDQYuKA4gWGeaToexDtpeWFCTznQ20RxONaj0VgP/y1Pcn Jk6QiFvBYNQSYwj6pp67C/HVJ7ifK5GkflXWtR4p0upr0lk2fhJgiWD+01AEZjQ45blV RqPsjzc2YL5vn1r9f0W68zbL/HDkAQFSrNNdq07rmzLYiiTeu8aVRGU3hLeWBKyT5pz6 VsV0HiR50ajHU3uX7lJl9lJOhY9IC+Zmpawdf6zd2w6oY/ABzVY7fx1alreh7RZ3MoVf yvgA== 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=TOBUM8vB9k+Xxdjqza7KhK358ltTbzzQWCOfZA+EL9g=; b=WyfSZbQ26KqAGTPUH641LlwVbz8qOL3y3mvKWH2rUpTSye3xBDnJ/hpujeYKVW5dD5 kAPSLftxd+pA0k++0vDpK03k7KPu6LVDl+04lGukYXegClLSn7Ta7IIu20rOfgxim73R zd18oyV6Ne1gllImOms7R2zaZO5WaP0dsYevx9/SIHG4lbdzif4j7fwomaiVNZuR9iH4 3tHDR5kSMyJmPAtdZ1AEED1/AnWFMpir6mzCY9mV2/YxJL9MjtdnCdOwMKiIO+yaX8RP s9ETH0hQtRJEVpDvRwWMLHEBfG+7PLH+VDYGawoUz1UmU0JO2qNBxiXR6/7sTheJjyEm gTyg== X-Gm-Message-State: APjAAAXuFSO9FZJbAj0Y/UAR8nrYC1wFkxDU24ZRqt3uiLsLGiUnLbpd UKTDoXif5+H1p1BuC8w476bFci3+ X-Google-Smtp-Source: APXvYqzvaw9ywozwnIrtfvf0l3w9DhGApC5qiW7Qgno+l/4Vphq2ggd7kZfNIrCf/GSi+USjPDDTzw== X-Received: by 2002:a1c:f10d:: with SMTP id p13mr66799wmh.56.1568644959319; Mon, 16 Sep 2019 07:42:39 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:06 +0200 Message-Id: <1568644929-9124-27-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 26/29] hw/i386/pc: Let pc_build_feature_control() take a FWCfgState argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Pass the FWCfgState object by argument, this will allow us to remove the PCMachineState argument later. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-13-philmd@redhat.com> --- hw/i386/pc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8f611cb..7213853 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1623,7 +1623,8 @@ void pc_cpus_init(PCMachineState *pcms) } } -static void pc_build_feature_control_file(PCMachineState *pcms) +static void pc_build_feature_control_file(PCMachineState *pcms, + FWCfgState *fw_cfg) { MachineState *ms = MACHINE(pcms); X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); @@ -1649,7 +1650,7 @@ static void pc_build_feature_control_file(PCMachineState *pcms) val = g_malloc(sizeof(*val)); *val = cpu_to_le64(feature_control_bits | FEATURE_CONTROL_LOCKED); - fw_cfg_add_file(pcms->fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); + fw_cfg_add_file(fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); } static void rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count) @@ -1695,7 +1696,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg); - pc_build_feature_control_file(pcms); + pc_build_feature_control_file(pcms, pcms->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); } From patchwork Mon Sep 16 14:42:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bGjvEq0f"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X98n1gJwz9sPn for ; Tue, 17 Sep 2019 01:27:21 +1000 (AEST) Received: from localhost ([::1]:35880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9suM-0000Us-P5 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53948) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDM-0006kR-RK for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDK-0007d9-HL for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:52 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:52194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDI-0007Zj-Cf for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: by mail-wm1-x335.google.com with SMTP id 7so82382wme.1 for ; Mon, 16 Sep 2019 07:42:41 -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=mdgTMF9pl4BjaOz4xSpG8Yfpg0WV/SHiKJbxxng3th0=; b=bGjvEq0fIQbsy2sfwAJ38MHa0kjeqt0MqVurmKvKLIDhOX9c7Baf+TF1V2A/w6vHof lmB2QDEP38D1RdHpUHjyuQ5CALyNHh7od+JaTiDPYmrYgzDl2y+dXw8PH9WCLKsFAfIZ 9a1CUhGGCxiaSATyKPKgjGL4UCh1SN0FreaaNnfFPghyGqTbHD2bOQx/lT+a7HuEBeUz R26qa/QId5OF2hfuDruahcAIRf2UV9lFgHTpQ8VR3Ja2PZIR1MOUD32rgHDBvEw7VTe2 0aOdk+15fg+F+yWcfiSZ46dSk2S2Q5a6a1I5ouJtIMlDXvCoMrlijDeIndADivx5F4jK BhuA== 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=mdgTMF9pl4BjaOz4xSpG8Yfpg0WV/SHiKJbxxng3th0=; b=bBH6RZhXCTxhM+9S7DwwwswM2VwX9X3GiOusJXiSVr5qVv0ZvbVf1HpUX3xiC8WVLK ygNtyBT0U3PydOCsFewoVzEEMegK2GqKg9pR6QT1bIIJMZLY62z588dQr7p9gR6C1mtc hbiUYSLa94l6VRr/PC32ao2UhEtOZorsPmdYQgB0AAvtIwZBwEuFFlS/B0pP271/P6s5 A6A4KWaxbRReI1eGQoVDlSKR0aP3hA5OKFlKw8F2CHUNQDzu5koF0Gq/c0BjCVjpTZS2 fQXZxX44ehy58ZcvK/jg94BUx8qcR2RhrupN3e+PZjp6LzYRIx8duEsWEKslT9uzA9HM xCnw== X-Gm-Message-State: APjAAAVIswBOJOswqwy6AUMVPABFlCYzKVvoYGVNQIz9V7QvXoHhozrs TZgRcsmbYnIQ2D0uNQVY3+iNlINX X-Google-Smtp-Source: APXvYqzhScHIb98OgpihoxXz0kz93TBQ5O1zs+RrzLh4pTGcVmpOmZCKdJ0lTqMlmo/MEc9CITHdjQ== X-Received: by 2002:a7b:c10c:: with SMTP id w12mr83372wmi.26.1568644960522; Mon, 16 Sep 2019 07:42:40 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:07 +0200 Message-Id: <1568644929-9124-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [PULL 27/29] hw/i386/pc: Let pc_build_feature_control() take a MachineState argument 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Let the pc_build_feature_control_file() function take a generic MachineState argument. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-14-philmd@redhat.com> --- hw/i386/pc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 7213853..438c485 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1623,10 +1623,9 @@ void pc_cpus_init(PCMachineState *pcms) } } -static void pc_build_feature_control_file(PCMachineState *pcms, +static void pc_build_feature_control_file(MachineState *ms, FWCfgState *fw_cfg) { - MachineState *ms = MACHINE(pcms); X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); CPUX86State *env = &cpu->env; uint32_t unused, ecx, edx; @@ -1696,7 +1695,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg); - pc_build_feature_control_file(pcms, pcms->fw_cfg); + pc_build_feature_control_file(MACHINE(pcms), pcms->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); } From patchwork Mon Sep 16 14:42:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AmyrUyQ6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X95b28gzz9sQm for ; Tue, 17 Sep 2019 01:24:33 +1000 (AEST) Received: from localhost ([::1]:35846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sre-0004uJ-F7 for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53922) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDK-0006jR-P4 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDI-0007bv-Ky for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:50 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37493) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDI-0007Zz-7R for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: by mail-wr1-x441.google.com with SMTP id i1so38606996wro.4 for ; Mon, 16 Sep 2019 07:42:42 -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=yV/n/mgO1W/0/jiaPYcXrk5/ziKrwU2IWT+KPvHpW0I=; b=AmyrUyQ6+2UsoDSk0L9O8hj9+k7/HFvVl2HZxaWSHAgVjvbGjiaDHOiTVq68F0BBbG LCgXCp8FOkWH6SMvkJv2nkS43o3dd01bFoVf1MsI9/MNosi26YHsuzlU3iK23OpW5VRR waN4tb9dvfY3B75BLp7z1JQBz58wRiIXxxVyIisUZUgkZDOQFs+E8PmwC2C6psdJiuRc LkSdOmS9IV7yFvvX6l8OyXc7yoX8bg7gYGMEO7ZibLSGveloSrJsacvgVIos+1MDGuKb SyTnN5XkVKqhECCEaSVrqGQRoKt+lmkyo4eoJf9R+9J8rXZu99sQ7zohLnsMzjevW4me xItw== 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=yV/n/mgO1W/0/jiaPYcXrk5/ziKrwU2IWT+KPvHpW0I=; b=jfVgpWaWo67r4Z2/wWrKebX84Hpm+md8vabTdry0e8CO6GUXJWC0EAX1c0i9s6sY6G ak9awoH+ePShSQY8X7teqPHAKqCh3sOnJHwseVQq4GPYx6gm686V3juFRXsCVvrH9Ub4 DY16uhBxkXfcN7GmCORb/k8gekhTBLvIn1Jn9FAiCaY0QsOEHwJHgP4JTisOBcM5tiRl +hmKOXSnpwZb0doS6menuX8BDUxHPmUTfVK9tft9ipL4T9Gu2/wSBBa9nJvbkduNQ3y2 Mt8EqjCS+VgxFX8BDGkODA8vMD2bd4g+P8QiczKb3tphS1WkUCDS9UkDl56QI7Kz1+vv 86rw== X-Gm-Message-State: APjAAAW6oyu2TE2a8cDeLDCOYGqQxf3rFNYHPVuETJ53H2DwtMxIL2qU BHs2aIHpThGcGlUk4a9IdT6ErnTI X-Google-Smtp-Source: APXvYqz1RlbjPjekDVU5ssekGTOoK/61oqbFtQyny3WCbwpm+z/DXdSo5BpNfgx9Fs8jbwA0u3wo6g== X-Received: by 2002:a5d:694e:: with SMTP id r14mr153953wrw.34.1568644961459; Mon, 16 Sep 2019 07:42:41 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:08 +0200 Message-Id: <1568644929-9124-29-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 28/29] hw/i386/pc: Rename pc_build_feature_control() as generic fw_cfg_build_* 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Now that the pc_build_feature_control_file() function has been refactored to not depend of PC specific types, rename it to a more generic name. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-15-philmd@redhat.com> --- hw/i386/pc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 438c485..9446596 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1623,8 +1623,8 @@ void pc_cpus_init(PCMachineState *pcms) } } -static void pc_build_feature_control_file(MachineState *ms, - FWCfgState *fw_cfg) +static void fw_cfg_build_feature_control(MachineState *ms, + FWCfgState *fw_cfg) { X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); CPUX86State *env = &cpu->env; @@ -1695,7 +1695,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg); - pc_build_feature_control_file(MACHINE(pcms), pcms->fw_cfg); + fw_cfg_build_feature_control(MACHINE(pcms), pcms->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); } From patchwork Mon Sep 16 14:42:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZJRH0t+I"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9wm707Zz9sPw for ; Tue, 17 Sep 2019 02:02:00 +1000 (AEST) Received: from localhost ([::1]:36352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9tRu-0002vI-2S for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 12:01:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53953) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sDN-0006kn-3P for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sDK-0007cy-FE for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:52 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sDI-0007aQ-9U for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:48 -0400 Received: by mail-wm1-x343.google.com with SMTP id o184so77148wme.3 for ; Mon, 16 Sep 2019 07:42:43 -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=lSmdP+pHZng8BEWPjDjiZZ2csyBsn+ff1HE03fLpH0c=; b=ZJRH0t+I69orU39wws4PL7LeBvfkH8pmrppDdA2zoUdEW+TPloFBPCXMwxbfrzcIaW KYcLOXFl8u2cWFKglM6XPEr79eupxUYyiCglej5H9QBD4L+9Nhna7/5wXUe8FmfNm/bm +pV2oS/jnX93Qy28l/drCasBhLqMFv0o0+KAjED/DZtzQA1gTWKO6W+L3QpmGlNyZiZh aV7egj1QRSNNDgMyoBP7c4no+9Ta2QVFl+XTyGUi+kuODoG0w2LZx1pI0B5PyOqaXSYO zLIJPDJjnEWZFkmtmTkm+pfhTc6IrY5V91zWwBclmRVhgv0rOYeAqloHd0/QilUI9sYa kBSw== 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=lSmdP+pHZng8BEWPjDjiZZ2csyBsn+ff1HE03fLpH0c=; b=LY1/pv/lboUofG3Ly25o8msarh8m9xGCtUiMP4xnKpbIh9jj57q7eOtS7PnlhoMUqC V/2h38IaiComcNFe2xUipG6Wd8WK22SYakT8yj3tBGqnFJcc+fSaSeVeXsP/W16hd1BI x4mmgDKF6srPwZYhpxXDCJqeDqFs7LY5pivyGDGTl51I3nCPws9FkxE5ZWNcEUgHkF+y E46WEI7GzrIfLLMclO0xABNBJFI4DspiPPGK7v2fVkEr5TyDFb51IGH9ov8SMWjqKHT9 GwptNWhyIf+XT2g6Nn3ReB9FeqGe1ivtY/lsI4f6wnRHVlohEWB4eiV6pmZ3jAFtRmir 9GtQ== X-Gm-Message-State: APjAAAXtZ1XLiURTimGaBTIF0aDkp3OFyJyba2dKjp6+33ZAymoIHLuo bKz7iqMpymT5XykzlksHDfeCx7bk X-Google-Smtp-Source: APXvYqxIgnIUMfvPaICfNonbaL3CcJj9ABMjH4Wq5dNNPLzfZRgd+7+ebz7ySbkDYHQh1eFHR+rCHA== X-Received: by 2002:a7b:c3c6:: with SMTP id t6mr46956wmj.5.1568644962463; Mon, 16 Sep 2019 07:42:42 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:42:09 +0200 Message-Id: <1568644929-9124-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 29/29] hw/i386/pc: Extract the x86 generic fw_cfg code 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Extract all the functions that are not PC-machine specific into the (arch-specific) fw_cfg.c file. This will allow other X86-machine to reuse these functions. Suggested-by: Samuel Ortiz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190818225414.22590-16-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/fw_cfg.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/fw_cfg.h | 7 +++ hw/i386/pc.c | 132 +---------------------------------------------------- 3 files changed, 145 insertions(+), 131 deletions(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 380a819..39b6bc6 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -13,8 +13,15 @@ */ #include "qemu/osdep.h" +#include "sysemu/numa.h" +#include "hw/acpi/acpi.h" +#include "hw/firmware/smbios.h" +#include "hw/i386/pc.h" #include "hw/i386/fw_cfg.h" +#include "hw/timer/hpet.h" #include "hw/nvram/fw_cfg.h" +#include "e820_memory_layout.h" +#include "kvm_i386.h" const char *fw_cfg_arch_key_name(uint16_t key) { @@ -36,3 +43,133 @@ const char *fw_cfg_arch_key_name(uint16_t key) } return NULL; } + +void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg) +{ + uint8_t *smbios_tables, *smbios_anchor; + size_t smbios_tables_len, smbios_anchor_len; + struct smbios_phys_mem_area *mem_array; + unsigned i, array_count; + X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); + + /* tell smbios about cpuid version and features */ + smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); + + smbios_tables = smbios_get_table_legacy(ms, &smbios_tables_len); + if (smbios_tables) { + fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, + smbios_tables, smbios_tables_len); + } + + /* build the array of physical mem area from e820 table */ + mem_array = g_malloc0(sizeof(*mem_array) * e820_get_num_entries()); + for (i = 0, array_count = 0; i < e820_get_num_entries(); i++) { + uint64_t addr, len; + + if (e820_get_entry(i, E820_RAM, &addr, &len)) { + mem_array[array_count].address = addr; + mem_array[array_count].length = len; + array_count++; + } + } + smbios_get_tables(ms, mem_array, array_count, + &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); + g_free(mem_array); + + if (smbios_anchor) { + fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables", + smbios_tables, smbios_tables_len); + fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor", + smbios_anchor, smbios_anchor_len); + } +} + +FWCfgState *fw_cfg_arch_create(MachineState *ms, + uint16_t boot_cpus, + uint16_t apic_id_limit) +{ + FWCfgState *fw_cfg; + uint64_t *numa_fw_cfg; + int i; + MachineClass *mc = MACHINE_GET_CLASS(ms); + const CPUArchIdList *cpus = mc->possible_cpu_arch_ids(ms); + int nb_numa_nodes = ms->numa_state->num_nodes; + + fw_cfg = 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, boot_cpus); + + /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: + * + * For machine types prior to 1.8, SeaBIOS needs FW_CFG_MAX_CPUS for + * building MPTable, ACPI MADT, ACPI CPU hotplug and ACPI SRAT table, + * that tables are based on xAPIC ID and QEMU<->SeaBIOS interface + * for CPU hotplug also uses APIC ID and not "CPU index". + * This means that FW_CFG_MAX_CPUS is not the "maximum number of CPUs", + * but the "limit to the APIC ID values SeaBIOS may see". + * + * So for compatibility reasons with old BIOSes we are stuck with + * "etc/max-cpus" actually being apic_id_limit + */ + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, apic_id_limit); + fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, + acpi_tables, acpi_tables_len); + 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()); + + fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); + /* allocate memory for the NUMA channel: one (64bit) word for the number + * of nodes, one word for each VCPU->node and one word for each node to + * hold the amount of memory. + */ + numa_fw_cfg = g_new0(uint64_t, 1 + apic_id_limit + nb_numa_nodes); + numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); + for (i = 0; i < cpus->len; i++) { + unsigned int apic_id = cpus->cpus[i].arch_id; + assert(apic_id < apic_id_limit); + numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id); + } + for (i = 0; i < nb_numa_nodes; i++) { + numa_fw_cfg[apic_id_limit + 1 + i] = + cpu_to_le64(ms->numa_state->nodes[i].node_mem); + } + fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg, + (1 + apic_id_limit + nb_numa_nodes) * + sizeof(*numa_fw_cfg)); + + return fw_cfg; +} + +void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg) +{ + X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); + CPUX86State *env = &cpu->env; + uint32_t unused, ecx, edx; + uint64_t feature_control_bits = 0; + uint64_t *val; + + cpu_x86_cpuid(env, 1, 0, &unused, &unused, &ecx, &edx); + if (ecx & CPUID_EXT_VMX) { + feature_control_bits |= FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; + } + + if ((edx & (CPUID_EXT2_MCE | CPUID_EXT2_MCA)) == + (CPUID_EXT2_MCE | CPUID_EXT2_MCA) && + (env->mcg_cap & MCG_LMCE_P)) { + feature_control_bits |= FEATURE_CONTROL_LMCE; + } + + if (!feature_control_bits) { + return; + } + + val = g_malloc(sizeof(*val)); + *val = cpu_to_le64(feature_control_bits | FEATURE_CONTROL_LOCKED); + fw_cfg_add_file(fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); +} diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h index 17a4bc3..e0856a3 100644 --- a/hw/i386/fw_cfg.h +++ b/hw/i386/fw_cfg.h @@ -9,6 +9,7 @@ #ifndef HW_I386_FW_CFG_H #define HW_I386_FW_CFG_H +#include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0) @@ -17,4 +18,10 @@ #define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3) #define FW_CFG_HPET (FW_CFG_ARCH_LOCAL + 4) +FWCfgState *fw_cfg_arch_create(MachineState *ms, + uint16_t boot_cpus, + uint16_t apic_id_limit); +void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg); +void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); + #endif diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9446596..e5b59ff 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -88,6 +88,7 @@ #include "qapi/qmp/qerror.h" #include "config-devices.h" #include "e820_memory_layout.h" +#include "fw_cfg.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -894,108 +895,6 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, } } -static void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg) -{ - uint8_t *smbios_tables, *smbios_anchor; - size_t smbios_tables_len, smbios_anchor_len; - struct smbios_phys_mem_area *mem_array; - unsigned i, array_count; - X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); - - /* tell smbios about cpuid version and features */ - smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); - - smbios_tables = smbios_get_table_legacy(ms, &smbios_tables_len); - if (smbios_tables) { - fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, - smbios_tables, smbios_tables_len); - } - - /* build the array of physical mem area from e820 table */ - mem_array = g_malloc0(sizeof(*mem_array) * e820_get_num_entries()); - for (i = 0, array_count = 0; i < e820_get_num_entries(); i++) { - uint64_t addr, len; - - if (e820_get_entry(i, E820_RAM, &addr, &len)) { - mem_array[array_count].address = addr; - mem_array[array_count].length = len; - array_count++; - } - } - smbios_get_tables(ms, mem_array, array_count, - &smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); - g_free(mem_array); - - if (smbios_anchor) { - fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables", - smbios_tables, smbios_tables_len); - fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor", - smbios_anchor, smbios_anchor_len); - } -} - -static FWCfgState *fw_cfg_arch_create(MachineState *ms, - uint16_t boot_cpus, - uint16_t apic_id_limit) -{ - FWCfgState *fw_cfg; - uint64_t *numa_fw_cfg; - int i; - MachineClass *mc = MACHINE_GET_CLASS(ms); - const CPUArchIdList *cpus = mc->possible_cpu_arch_ids(ms); - int nb_numa_nodes = ms->numa_state->num_nodes; - - fw_cfg = 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, boot_cpus); - - /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: - * - * For machine types prior to 1.8, SeaBIOS needs FW_CFG_MAX_CPUS for - * building MPTable, ACPI MADT, ACPI CPU hotplug and ACPI SRAT table, - * that tables are based on xAPIC ID and QEMU<->SeaBIOS interface - * for CPU hotplug also uses APIC ID and not "CPU index". - * This means that FW_CFG_MAX_CPUS is not the "maximum number of CPUs", - * but the "limit to the APIC ID values SeaBIOS may see". - * - * So for compatibility reasons with old BIOSes we are stuck with - * "etc/max-cpus" actually being apic_id_limit - */ - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, apic_id_limit); - fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, - acpi_tables, acpi_tables_len); - 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()); - - fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); - /* allocate memory for the NUMA channel: one (64bit) word for the number - * of nodes, one word for each VCPU->node and one word for each node to - * hold the amount of memory. - */ - numa_fw_cfg = g_new0(uint64_t, 1 + apic_id_limit + nb_numa_nodes); - numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); - for (i = 0; i < cpus->len; i++) { - unsigned int apic_id = cpus->cpus[i].arch_id; - assert(apic_id < apic_id_limit); - numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id); - } - for (i = 0; i < nb_numa_nodes; i++) { - numa_fw_cfg[apic_id_limit + 1 + i] = - cpu_to_le64(ms->numa_state->nodes[i].node_mem); - } - fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg, - (1 + apic_id_limit + nb_numa_nodes) * - sizeof(*numa_fw_cfg)); - - return fw_cfg; -} - static long get_file_size(FILE *f) { long where, size; @@ -1623,35 +1522,6 @@ void pc_cpus_init(PCMachineState *pcms) } } -static void fw_cfg_build_feature_control(MachineState *ms, - FWCfgState *fw_cfg) -{ - X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); - CPUX86State *env = &cpu->env; - uint32_t unused, ecx, edx; - uint64_t feature_control_bits = 0; - uint64_t *val; - - cpu_x86_cpuid(env, 1, 0, &unused, &unused, &ecx, &edx); - if (ecx & CPUID_EXT_VMX) { - feature_control_bits |= FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; - } - - if ((edx & (CPUID_EXT2_MCE | CPUID_EXT2_MCA)) == - (CPUID_EXT2_MCE | CPUID_EXT2_MCA) && - (env->mcg_cap & MCG_LMCE_P)) { - feature_control_bits |= FEATURE_CONTROL_LMCE; - } - - if (!feature_control_bits) { - return; - } - - val = g_malloc(sizeof(*val)); - *val = cpu_to_le64(feature_control_bits | FEATURE_CONTROL_LOCKED); - fw_cfg_add_file(fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); -} - static void rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count) { if (cpus_count > 0xff) {