From nobody Wed Nov 13 07:24:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1704814749; cv=none; d=zohomail.com; s=zohoarc; b=Y+R1dhB/yG4g8woOGWqOvqaFW44pf3ZOoJKrJ+DM/UvltdT3csuEoqd/3QP/vO00VWFBwi2fDHxdRNCHS/n/7cjpiL19eTvC5yRZi2vPnOqUw5hhjiaEUmazg5dEQdDIvTMCJVQJhAwks+NOeZ4uNK8OWmGDERjxSP1SmaNhRE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704814749; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3Tyvj96yu+ExmEaYuZYuzT4Vsi1GPehED1a8sOXZbwo=; b=OnLuBNnenXDzawbPP+AZ2g8ZT41af+vBPzBiZnI8Cv2Yakqj6doVaPcF5cFiZYsVEE2NH3R+D9+h0FdGmIKchOuwY1cbhZ61SBgkYL8AK3Ow7uTWKcYEzSzrUFOieaepu7W6vVqJyRpopKlrX9ImgUK9zrUXABw/nEcrq9i8+NY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1704814749065667.3004199008617; Tue, 9 Jan 2024 07:39:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.664702.1034826 (Exim 4.92) (envelope-from ) id 1rNEBi-0000ZN-OM; Tue, 09 Jan 2024 15:38:46 +0000 Received: by outflank-mailman (output) from mailman id 664702.1034826; Tue, 09 Jan 2024 15:38:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rNEBi-0000Yo-KM; Tue, 09 Jan 2024 15:38:46 +0000 Received: by outflank-mailman (input) for mailman id 664702; Tue, 09 Jan 2024 15:38:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rNEBg-00081N-LT for xen-devel@lists.xenproject.org; Tue, 09 Jan 2024 15:38:44 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2a52ca72-af05-11ee-9b0f-b553b5be7939; Tue, 09 Jan 2024 16:38:41 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-555144cd330so3811816a12.2 for ; Tue, 09 Jan 2024 07:38:41 -0800 (PST) Received: from EMEAENGAAD19049.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id fi3-20020a170906da0300b00a2adb417051sm1153685ejb.216.2024.01.09.07.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 07:38:40 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2a52ca72-af05-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1704814721; x=1705419521; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Tyvj96yu+ExmEaYuZYuzT4Vsi1GPehED1a8sOXZbwo=; b=XTGrQ8P4be3M0Vs5MtFzjdjzkSl3aZmMuFVzrPW/xLJrESOXbFgA0WzCEJyOUzjqyx AdTfrMG8kyv9s1L1QTSuEY6dCfvQa7jnqMNBYdGXcedBLcOixpDRPH2lE4QrNbQjbyXn wf/TgSSfSP/hkywnsSzqEe2blQoQtrztvpqQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704814721; x=1705419521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Tyvj96yu+ExmEaYuZYuzT4Vsi1GPehED1a8sOXZbwo=; b=nT0K1q0BGTUA8VRiAAvzI4aLpOnP+GFT030fGcaIOLzrql3TLAmjd8DDFKzBi6UbJF 1NHMHXom48K32Drpy7Dx0c5OZWrfTPfpf6+Oh0w6zb6Ck2a3LbQS1sFtw++628PzfX0e J+syKXI6hc90Nt3b3JMoS5t7s2bEt/4g09mJSPpwMep9yuu9stuVLIdUaq5mKjfka/VV 8U8ma+9m6wDeqrA10qTjtDTOQDZ4/JvyuCRfzKX/XtmII/yPbr74OmS7wpgyNe/iNqvo SS3UCS+k0OC6ojuzXBE2/wEe19P1urg4Y/g5aCO+FutzUw5dKMmop64ysZOe4Bg0mA+p cfPA== X-Gm-Message-State: AOJu0YzJbsWgV5LNQDSCJIdh/Ij3uuakwdkws+pTBBNI72c+G2a/vX1j bSp7ENdcIuP2ardwK0snu6EKOuqrrALqYxsrOG+x+94SJ8A= X-Google-Smtp-Source: AGHT+IEFk0EhIfe0ycvYEIqj7VI5sVFnxOOeuQm8MgIUUKNKFkGLeTC02i742HgQRpSTYVgVXSDvpw== X-Received: by 2002:a17:906:dfe2:b0:a26:e9fe:f59f with SMTP id lc2-20020a170906dfe200b00a26e9fef59fmr697946ejc.133.1704814721012; Tue, 09 Jan 2024 07:38:41 -0800 (PST) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 3/6] xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader Date: Tue, 9 Jan 2024 15:38:31 +0000 Message-Id: <20240109153834.4192-4-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240109153834.4192-1-alejandro.vallejo@cloud.com> References: <20240109153834.4192-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1704814750565100005 Content-Type: text/plain; charset="utf-8" A future patch will use these in hvmloader, which is freestanding, but lacks the Xen code. The following changes fix the compilation errors. * string.h =3D> Remove memset() usages and bzero through assignments * inttypes.h =3D> Use stdint.h (it's what it should've been to begin with) * errno.h =3D> Use xen/errno.h instead No functional change intended. Signed-off-by: Alejandro Vallejo --- xen/lib/x86/cpuid.c | 12 ++++++------ xen/lib/x86/private.h | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c index eb7698dc73..4a138c3a11 100644 --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -5,8 +5,8 @@ static void zero_leaves(struct cpuid_leaf *l, unsigned int first, unsigned int last) { - if ( first <=3D last ) - memset(&l[first], 0, sizeof(*l) * (last - first + 1)); + for (l =3D &l[first]; first <=3D last; first++, l++ ) + *l =3D (struct cpuid_leaf){}; } =20 unsigned int x86_cpuid_lookup_vendor(uint32_t ebx, uint32_t ecx, uint32_t = edx) @@ -244,7 +244,7 @@ void x86_cpu_policy_clear_out_of_range_leaves(struct cp= u_policy *p) ARRAY_SIZE(p->basic.raw) - 1); =20 if ( p->basic.max_leaf < 4 ) - memset(p->cache.raw, 0, sizeof(p->cache.raw)); + p->cache =3D (typeof(p->cache)){}; else { for ( i =3D 0; (i < ARRAY_SIZE(p->cache.raw) && @@ -255,13 +255,13 @@ void x86_cpu_policy_clear_out_of_range_leaves(struct = cpu_policy *p) } =20 if ( p->basic.max_leaf < 7 ) - memset(p->feat.raw, 0, sizeof(p->feat.raw)); + p->feat =3D (typeof(p->feat)){}; else zero_leaves(p->feat.raw, p->feat.max_subleaf + 1, ARRAY_SIZE(p->feat.raw) - 1); =20 if ( p->basic.max_leaf < 0xb ) - memset(p->topo.raw, 0, sizeof(p->topo.raw)); + p->topo =3D (typeof(p->topo)){}; else { for ( i =3D 0; (i < ARRAY_SIZE(p->topo.raw) && @@ -272,7 +272,7 @@ void x86_cpu_policy_clear_out_of_range_leaves(struct cp= u_policy *p) } =20 if ( p->basic.max_leaf < 0xd || !cpu_policy_xstates(p) ) - memset(p->xstate.raw, 0, sizeof(p->xstate.raw)); + p->xstate =3D (typeof(p->xstate)){}; else { /* This logic will probably need adjusting when XCR0[63] gets used= . */ diff --git a/xen/lib/x86/private.h b/xen/lib/x86/private.h index 60bb82a400..4b8cb97e64 100644 --- a/xen/lib/x86/private.h +++ b/xen/lib/x86/private.h @@ -17,12 +17,14 @@ =20 #else =20 -#include -#include +#include #include #include -#include =20 +enum { +#define XEN_ERRNO(ident, rc) ident =3D (rc), +#include +}; #include #include =20 --=20 2.34.1