public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: [PATCH 08/11] OvmfPkg/IoMmuDxe: IoMmuMap(): log nicer and more informative DEBUG msgs
Date: Wed, 30 Aug 2017 17:53:14 +0200	[thread overview]
Message-ID: <20170830155317.30917-9-lersek@redhat.com> (raw)
In-Reply-To: <20170830155317.30917-1-lersek@redhat.com>

Log all relevant IN and IN OUT parameters on entry.

When exiting with success, log all relevant OUT and IN OUT parameters.
Don't log OUT and IN OUT parameters that are never set or changed after
entering the function (i.e., *NumberOfBytes).

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/IoMmuDxe/AmdSevIoMmu.c | 31 ++++++++++++++++++--
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
index ec625166f459..59cee95c0e21 100644
--- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
+++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
@@ -44,6 +44,19 @@ STATIC LIST_ENTRY mRecycledMapInfos = INITIALIZE_LIST_HEAD_VARIABLE (
 
 #define COMMON_BUFFER_SIG SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F', 'R')
 
+//
+// ASCII names for EDKII_IOMMU_OPERATION constants, for debug logging.
+//
+STATIC CONST CHAR8 * CONST
+mBusMasterOperationName[EdkiiIoMmuOperationMaximum] = {
+  "Read",
+  "Write",
+  "CommonBuffer",
+  "Read64",
+  "Write64",
+  "CommonBuffer64"
+};
+
 //
 // The following structure enables Map() and Unmap() to perform in-place
 // decryption and encryption, respectively, for BusMasterCommonBuffer[64]
@@ -116,6 +129,18 @@ IoMmuMap (
   COMMON_BUFFER_HEADER                              *CommonBufferHeader;
   VOID                                              *DecryptionSource;
 
+  DEBUG ((
+    DEBUG_VERBOSE,
+    "%a: Operation=%a Host=0x%p Bytes=0x%Lx\n",
+    __FUNCTION__,
+    ((Operation >= 0 &&
+      Operation < ARRAY_SIZE (mBusMasterOperationName)) ?
+     mBusMasterOperationName[Operation] :
+     "Invalid"),
+    HostAddress,
+    (UINT64)((NumberOfBytes == NULL) ? 0 : *NumberOfBytes)
+    ));
+
   if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL ||
       Mapping == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -281,12 +306,12 @@ IoMmuMap (
 
   DEBUG ((
     DEBUG_VERBOSE,
-    "%a PlainText 0x%Lx Crypted 0x%Lx Pages 0x%Lx Bytes 0x%Lx\n",
+    "%a: Mapping=0x%p Device(PlainText)=0x%Lx Crypted=0x%Lx Pages=0x%Lx\n",
     __FUNCTION__,
+    MapInfo,
     MapInfo->PlainTextAddress,
     MapInfo->CryptedAddress,
-    (UINT64)MapInfo->NumberOfPages,
-    (UINT64)MapInfo->NumberOfBytes
+    (UINT64)MapInfo->NumberOfPages
     ));
 
   return EFI_SUCCESS;
-- 
2.14.1.3.gb7cf6e02401b




  parent reply	other threads:[~2017-08-30 15:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 15:53 [PATCH 00/11] OvmfPkg: improve SEV-related DEBUG messages Laszlo Ersek
2017-08-30 15:53 ` [PATCH 01/11] OvmfPkg/BaseMemEncryptSevLib: unify encrypt/decrypt " Laszlo Ersek
2017-08-30 15:53 ` [PATCH 02/11] OvmfPkg/BaseMemEncryptSevLib: break DEBUG calls to multiple lines Laszlo Ersek
2017-08-30 15:53 ` [PATCH 03/11] OvmfPkg/BaseMemEncryptSevLib: clean up DEBUG prefixes Laszlo Ersek
2017-08-30 15:53 ` [PATCH 04/11] OvmfPkg/BaseMemEncryptSevLib: clean up debug logging of PhysicalAddress Laszlo Ersek
2017-08-30 15:53 ` [PATCH 05/11] OvmfPkg/BaseMemEncryptSevLib: promote DEBUG_WARN levels to DEBUG_ERROR Laszlo Ersek
2017-08-30 15:53 ` [PATCH 06/11] OvmfPkg/BaseMemEncryptSevLib: clean up upper-case / lower-case in DEBUGs Laszlo Ersek
2017-08-30 15:53 ` [PATCH 07/11] OvmfPkg/BaseMemEncryptSevLib: fix typos in DEBUG messages Laszlo Ersek
2017-08-30 15:53 ` Laszlo Ersek [this message]
2017-08-30 15:53 ` [PATCH 09/11] OvmfPkg/IoMmuDxe: IoMmuUnmap(): clean up DEBUG message Laszlo Ersek
2017-08-30 15:53 ` [PATCH 10/11] OvmfPkg/IoMmuDxe: IoMmuAllocateBuffer(): nicer and more informative DEBUGs Laszlo Ersek
2017-08-30 15:53 ` [PATCH 11/11] OvmfPkg/IoMmuDxe: IoMmuFreeBuffer(): clean up DEBUG message Laszlo Ersek
2017-08-31 15:14 ` [PATCH 00/11] OvmfPkg: improve SEV-related DEBUG messages Brijesh Singh
2017-09-01 12:23   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830155317.30917-9-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox