From nobody Fri Nov 22 18:08:52 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=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1716383854; cv=none; d=zohomail.com; s=zohoarc; b=gPXPfpo2sef58BAUeFqyjBdKL24lm5+M2qyj6zvY+AAIVW8hTGmsIhBFLa3cN+YtrqoVf/8sw5QdRQVQX2SQmDG+dGYHOKg8t7jbGalyzEVKZZo+QUgVCqOi1aSDz9DK7yHw01qhIGXRZHVMvpa4voG0oSAGFj63TT9WU65ci5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716383854; h=Content-Type: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=oUlYslBBFz8SJFw2HFYr2U4IW4XAKwPKEvjfJVvwvsQ=; b=G+x+XX4ws0Ya3JDJCM47gc8zi1bKwXqPImtKn+R24uZBZWT5KVwrA4Thj6nkeek486DFH3J6KiExnjaG8eb5O3CVbiZnqyqmNZRCBgR+5LpEY5b8q6IS8/O4e0MnOAhRjAJG1jC0moMwgoWfi7odCbrRd1b1qb8nUn/ZfknCXs0= 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 1716383854986686.4524460317581; Wed, 22 May 2024 06:17:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.727617.1132186 (Exim 4.92) (envelope-from ) id 1s9lqG-000804-Vt; Wed, 22 May 2024 13:17:16 +0000 Received: by outflank-mailman (output) from mailman id 727617.1132186; Wed, 22 May 2024 13:17:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s9lqG-0007zt-SG; Wed, 22 May 2024 13:17:16 +0000 Received: by outflank-mailman (input) for mailman id 727617; Wed, 22 May 2024 13:17:15 +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 1s9lqF-0006aV-NS for xen-devel@lists.xenproject.org; Wed, 22 May 2024 13:17:15 +0000 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [2607:f8b0:4864:20::82d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9a689107-183d-11ef-b4bb-af5377834399; Wed, 22 May 2024 15:17:14 +0200 (CEST) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-43f91aac792so5822751cf.1 for ; Wed, 22 May 2024 06:17:14 -0700 (PDT) Received: from andrew-laptop.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df8308580sm168782291cf.66.2024.05.22.06.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 06:17:12 -0700 (PDT) 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: 9a689107-183d-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1716383832; x=1716988632; 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=oUlYslBBFz8SJFw2HFYr2U4IW4XAKwPKEvjfJVvwvsQ=; b=j1fHsoszGxka524cwGAFbgs2MRpdTBw+DZlVvfJw1OJT+j+y612ZV9xcYZJyn+ixyP Kg7ryvhWPeB6EHsNzltpY6qoVMKw/r5gw2Q6DVU/o70NsM6VSzdce2c4TS3m8qrlZMSm Yf0/+wgEKzHI9YRLln9ZHLNrTThNQiApp6Ggc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716383832; x=1716988632; 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=oUlYslBBFz8SJFw2HFYr2U4IW4XAKwPKEvjfJVvwvsQ=; b=mxlzf9j7L/CUYb9ZXxENmtYvxSmw7qh5Kh+aIH8Ko9F1R0n3AtNpNJDpNrUXBRpWhd eixcjpWjnNZC3Bw6/9R3kwd6OPOlAGHMbn8kIjgepnAPg+ena7+xl21BU8OT/yOHd95V D25j0CQNmcYdrQOp7Koj0EMZ/okT13AMOqY8kyn8xUC6ZB4ka+IBzsWKhTOLVr+JZs+i +RT+KA1IQEMAVAcxu2eZxmmCQulTOSXDvtNF/RCOtU0C8gNxSVYtTjq/ZltWOdtdk0jI sQWv/Kbd3dNkVUl9rZthZx9CbQGKrIWUXY2a7c59s/izbKyuQDe9KacaYZJ80sYhisZS Azeg== X-Gm-Message-State: AOJu0Yze0GC9Ufr8GIgwi2IpOT6sIcfmuupiQsl5QTA1tKuDSEuAW6WL l1IO5Zlbg9xoPhBDzIddVqMDjBv/r3FN6ETZ7QNwLHmPWlUuzz0iVm6jeHXPQxaJy06g/wbmetc /UT8= X-Google-Smtp-Source: AGHT+IHgcNFz0cHXAnovqybxYLcIlXH3BYwKJQGW2bzSQcH9gB41flGGy3toNyocqY82GQ5X3vsOTw== X-Received: by 2002:ac8:598e:0:b0:43a:3fce:32c2 with SMTP id d75a77b69052e-43f7a28dfd5mr195215021cf.3.1716383832534; Wed, 22 May 2024 06:17:12 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , George Dunlap Subject: [PATCH v2 3/4] x86/shadow: Rework trace_shadow_emulate_other() as sh_trace_gfn_va() Date: Wed, 22 May 2024 14:17:02 +0100 Message-Id: <20240522131703.30839-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522131703.30839-1-andrew.cooper3@citrix.com> References: <20240522131703.30839-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1716383856217100001 sh_trace_gfn_va() is very similar to sh_trace_gl1e_va(), and a rather short= er name than trace_shadow_emulate_other(). Like sh_trace_gl1e_va(), there is = no need to pack the trace record. No functional change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: George Dunlap v2: * New --- xen/arch/x86/mm/shadow/multi.c | 40 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index f0a9cc527c0b..d2fe4e148fe0 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2010,29 +2010,30 @@ static void sh_trace_gl1e_va(uint32_t event, guest_= l1e_t gl1e, guest_va_t va) } } =20 -static inline void trace_shadow_emulate_other(u32 event, - guest_va_t va, - gfn_t gfn) +/* Shadow trace event with a gfn, linear address and flags. */ +static void sh_trace_gfn_va(uint32_t event, gfn_t gfn, guest_va_t va) { if ( tb_init_done ) { - struct __packed { - /* for PAE, guest_l1e may be 64 while guest_va may be 32; - so put it first for alignment sake. */ + struct { + /* + * For GUEST_PAGING_LEVELS=3D3 (PAE paging), gfn is 64 while + * guest_va is 32. Put it first to avoid padding. + */ #if GUEST_PAGING_LEVELS =3D=3D 2 - u32 gfn; + uint32_t gfn; #else - u64 gfn; + uint64_t gfn; #endif guest_va_t va; - } d; - - event |=3D ((GUEST_PAGING_LEVELS-2)<<8); - - d.gfn=3Dgfn_x(gfn); - d.va =3D va; + uint32_t flags; + } d =3D { + .gfn =3D gfn_x(gfn), + .va =3D va, + .flags =3D this_cpu(trace_shadow_path_flags), + }; =20 - trace(event, sizeof(d), &d); + sh_trace(event, sizeof(d), &d); } } =20 @@ -2603,8 +2604,7 @@ static int cf_check sh_page_fault( mfn_x(gmfn)); perfc_incr(shadow_fault_emulate_failed); shadow_remove_all_shadows(d, gmfn); - trace_shadow_emulate_other(TRC_SHADOW_EMULATE_UNSHADOW_USER, - va, gfn); + sh_trace_gfn_va(TRC_SHADOW_EMULATE_UNSHADOW_USER, gfn, va); goto done; } =20 @@ -2683,8 +2683,7 @@ static int cf_check sh_page_fault( } #endif shadow_remove_all_shadows(d, gmfn); - trace_shadow_emulate_other(TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ, - va, gfn); + sh_trace_gfn_va(TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ, gfn, va); return EXCRET_fault_fixed; } =20 @@ -2739,8 +2738,7 @@ static int cf_check sh_page_fault( * though, this is a hint that this page should not be shadowed. */ shadow_remove_all_shadows(d, gmfn); =20 - trace_shadow_emulate_other(TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED, - va, gfn); + sh_trace_gfn_va(TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED, gfn, va); goto emulate_done; } =20 --=20 2.30.2