From nobody Sat May 4 22:13:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1580117961; cv=none; d=zohomail.com; s=zohoarc; b=fZktXsGBpCANu62gpvJOCMaQ02bRW+fkRqUXv3EWsAIk+JEDmBT/uSJbV3w5zFkokuzAKf2AlK9/nHwm+WyR8sBlh0H6drEyPHHXMYIL0THpLeQ3a2IxewdtrN+ni8tCVjSVnFILfpFH0jxJbBWmXaDeCdtT9gjlBbBnPIXHb2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1580117961; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fW6yoyWDR0ftK+1+D1hKTaPtsZrD7PAmIKzsTUgPQQg=; b=lssqNAaOBU/W5tyC6bT7Ku4y7U8B0aVxHCsG7nRKvRWTY5/eQWWOFTDMp+fBab3b90itoVZ3N/QyIwKOn+0mmt/5AHI6gxpfGFeUFUHdthDNvXb4mABA2q2fe3ZvuDmEC+G1qvp1/w5nNRkG9F1chk6tu8oX3I0tF8YuMfEqK2g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580117961702693.3741194967815; Mon, 27 Jan 2020 01:39:21 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw0qh-00089f-Ns; Mon, 27 Jan 2020 09:38:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw0qf-00089a-U6 for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 09:38:25 +0000 Received: from mail-wm1-f65.google.com (unknown [209.85.128.65]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id becae878-40e8-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 09:38:17 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id a9so1303321wmj.3 for ; Mon, 27 Jan 2020 01:38:17 -0800 (PST) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id a1sm19787707wrr.80.2020.01.27.01.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 01:38:15 -0800 (PST) X-Inumbo-ID: becae878-40e8-11ea-9fd7-bc764e2007e4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7yDYDUuBnKkaTfZ4nQFYkDd4vx/FuI+FIuhi5mEE3iM=; b=NPF9Z5hRmm6gWMuAAb4yzb0Tm6/fwsl1fR7WhljM/toLg0GWpTzRwIhwUgRgAYm9D+ 0hiIOzD6/cnpIT1YuRn4X8CsfGvpqgq5LqrjL0DPGrVsSkaVbrB9nZqN3z0wIiCJUXWk DYgiS2VLDx/aRcGzYt4GMaNBlJ9NmVrIGz9qWSUCJOdVJsX9RbUQu3kR44zRkn459bO3 LzvDMPc6HMWQrOe+pEOmAfQo+DhkA9jb3Ssi9/G3vY94NexdXt/pOaPwG6cvHyJbAC6c g9kMsFCfk6YfgsZKjAX2KK2MchExqicbRk9hr3GmA3UC08dprAGa0IVoJrcQYCHX28vm c9aw== X-Gm-Message-State: APjAAAWJWg8CpXlcjQfqTwkhnBNg2F2RGA2ml9iLT0rMdwlMZ6SlaLJd OOJHIkLCE2/XMzwuiaKrioyt7OGrhFs= X-Google-Smtp-Source: APXvYqwDx+bf4y/0kiWFSH257Q8SRe0amczRu1cYZfqZ/PvhnO84CkFSfPfTVXqyBDcIylDZ8KuhTQ== X-Received: by 2002:a05:600c:d5:: with SMTP id u21mr12768315wmm.98.1580117896058; Mon, 27 Jan 2020 01:38:16 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 27 Jan 2020 09:38:08 +0000 Message-Id: <20200127093808.31373-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] xen/x86: domain: Remove specific case when allocating struct domain X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Andrew Cooper , Julien Grall , David Woodhouse , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall Commit 8916fcf4577 "x86/domain: compile with lock_profile=3Dy enabled" allowed the struct domain to use more than a PAGE_SIZE (i.e 4096). However, the function free_domheap_struct() will only free the first page. We could modify the free part to free the correct number of pages, but the structure has been fitting in a page (even with lock profile enabled) since commit 428607a410 "x86: shrink 'struct domain', was already PAGE_SIZE" (part of Xen 4.7). Therefore, the specific case for lock profile is now removed. This is not a security issue because struct domain can only be bigger than a page size for lock profiling. The feature can only be selected in DEBUG and EXPERT mode. Fixes: 8916fcf4577 ("x86/domain: compile with lock_profile=3Dy enabled") Reported-by: David Woodhouse Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- This replace the original approach: https://lists.xenproject.org/archives/html/xen-devel/2020-01/msg01546.html --- xen/arch/x86/domain.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 28fefa1f81..f53ae5ff86 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -313,7 +313,6 @@ static unsigned int __init noinline _domain_struct_bits= (void) struct domain *alloc_domain_struct(void) { struct domain *d; - unsigned int order =3D get_order_from_bytes(sizeof(*d)); #ifdef CONFIG_BIGMEM const unsigned int bits =3D 0; #else @@ -327,18 +326,10 @@ struct domain *alloc_domain_struct(void) bits =3D _domain_struct_bits(); #endif =20 - -#ifndef CONFIG_DEBUG_LOCK_PROFILE BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); -#endif - d =3D alloc_xenheap_pages(order, MEMF_bits(bits)); + d =3D alloc_xenheap_pages(0, MEMF_bits(bits)); if ( d !=3D NULL ) - { - unsigned int sz; - - for ( sz =3D 0; sz < (PAGE_SIZE << order); sz +=3D PAGE_SIZE ) - clear_page((void *)d + sz); - } + clear_page(d); return d; } =20 --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel