From nobody Sat Nov 23 19:54:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731155844; cv=none; d=zohomail.com; s=zohoarc; b=gVEaTOQhliuQHFAYDItOmFV/2OKtv7P7T8WGGzNyURUbWNdBsgUkNnN70PoOMuWWQMQUo0qSd8/YW4jTvyw84pgbTMxL3bGU4OiREsbeSESBz6xTteVrVKFB+6kCYU91VGm0qbSNkZtHZJZlH6auGKu18S6EqaRuVk10XV3yNBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731155844; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I22Vm01k91Exl/3tx9OtOL6Tgt75qZKLVbyFVyDph9Y=; b=AUEDFvhN1xMF/HdNa0Ng8pthjvwckv1dT+vtcvLR34pAr9RDtVk8Rbs/3R55vD1UQIkdyj8MDx41Js8tPsljcOn2zTrBzIxW+IEIge+r2/G7PAuhwpNv1TJqKtawvfwuMT0yGQVAILUmpEnyXL2QU/A3PJZH6Mgdppb8dYc06hY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731155844974376.303174325579; Sat, 9 Nov 2024 04:37:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9kdT-0001vb-L5; Sat, 09 Nov 2024 07:32:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9kdL-0001rR-0z for qemu-devel@nongnu.org; Sat, 09 Nov 2024 07:32:08 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9kdJ-0007AW-F4 for qemu-devel@nongnu.org; Sat, 09 Nov 2024 07:32:06 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-20c803787abso25838265ad.0 for ; Sat, 09 Nov 2024 04:32:05 -0800 (PST) Received: from localhost.localdomain ([103.103.35.149]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177e6a429sm45257045ad.238.2024.11.09.04.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 04:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731155523; x=1731760323; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I22Vm01k91Exl/3tx9OtOL6Tgt75qZKLVbyFVyDph9Y=; b=Ua0ZuS08dmzkHBiwr3b/i2nwMiJDZuJYOwfhiWecaGDGWCkeEoJ/MccXKzU3XAtLAq WeR1cIkJt8xGGD/o91cMQOiiio11DZzcfcbH+mKiHxq05AKygBwEWHxwJ0UEUGIqTfi5 uzYygZ6YFhWGLqbXSU/yZkx4XfCKwRiaNIN5cPEhoRAB0HCivdjy7s40m4Q+H6OstGl5 E1UO+bYUsP2o+4OCC4NMnSCr9h/C2N7q9YAkbGRAZJuz55Q/V/lXlPJMW+APgodQsDEa sSGhc1+ZljPAAtA0BzKE2fZN9anvNEedmYHs+qHLqneEyxqOlnEE9MRA9vX9LC/WtQBQ RR+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731155523; x=1731760323; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I22Vm01k91Exl/3tx9OtOL6Tgt75qZKLVbyFVyDph9Y=; b=TxGrPhiYhTP48s4hRCQhuDlSEsAavCGW+1q0q4bwHl9W31VXpYuaTWKZHqXptBNJf/ tJcTYP8jbrDnTH9S3LAnjxON6mjAWdzGMHy8LmIJg+vvTzx9kf4rlWqpw81zt+ykPMy1 Pg7wG+G+6qfQFEiupDsAtciziWM+lrDxxSM6MJ2YoWqVpIz4vNxnHd0a+NM49pMHH9ZU cC0dot5YPoZihw4jQr5pfj02sY2yGfT53+oRri9CmYOl92XFyx2efz+Kdw6RZYDVFvhT DSNCrnjvA4Oyz/fKKic+IAQXd5NlH1Ma/splr6paRz8yAUTATntnzuabxpO/cJth3H4v u8mQ== X-Gm-Message-State: AOJu0Yw647lO93avMGhfqrNr4y751++0JI3oWJOJCEwP2zGVLJUTlrEi DXwsC6yPfCzlSpSqTIBnDZruLvEGHTIhFHV+Ba7sJWcnLCxXtAbrbvJl8g== X-Google-Smtp-Source: AGHT+IGcd///f1aSWcqZh++Jq3x7EmhiC9o/yN+GDGmtmJE2Th7pnFRJSqeSgKsKFnSG0cP+AM/dBA== X-Received: by 2002:a17:903:32c4:b0:20c:c9ac:bd0d with SMTP id d9443c01a7336-2118377eb96mr94083505ad.19.1731155523538; Sat, 09 Nov 2024 04:32:03 -0800 (PST) From: Dorjoy Chowdhury To: qemu-devel@nongnu.org Cc: graf@amazon.com, pbonzini@redhat.com Subject: [PATCH] device/virtio-nsm: Support string data for extendPCR Date: Sat, 9 Nov 2024 18:32:08 +0600 Message-Id: <20241109123208.24281-1-dorjoychy111@gmail.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=dorjoychy111@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731155846782116600 Content-Type: text/plain; charset="utf-8" NSM device in AWS Nitro Enclaves supports extending with both bytestring and string data. Signed-off-by: Dorjoy Chowdhury --- hw/virtio/virtio-nsm.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c index a3db8eef3e..6830fcfe17 100644 --- a/hw/virtio/virtio-nsm.c +++ b/hw/virtio/virtio-nsm.c @@ -444,7 +444,7 @@ static bool handle_describe_pcr(VirtIONSM *vnsm, struct= iovec *request, * key =3D String("index"), * value =3D Uint8(pcr), * key =3D String("data"), - * value =3D Byte_String(data), + * value =3D Byte_String(data) || String(data), * } * } * } @@ -504,14 +504,21 @@ static enum NSMResponseTypes get_nsm_extend_pcr_req(u= int8_t *req, size_t len, =20 if (cbor_string_length(pair[i].key) =3D=3D 4 && memcmp(str, "data", 4) =3D=3D 0) { - if (!cbor_isa_bytestring(pair[i].value)) { + if (cbor_isa_bytestring(pair[i].value)) { + str =3D cbor_bytestring_handle(pair[i].value); + if (!str) { + goto cleanup; + } + nsm_req->data_len =3D cbor_bytestring_length(pair[i].value= ); + } else if (cbor_isa_string(pair[i].value)) { + str =3D cbor_string_handle(pair[i].value); + if (!str) { + goto cleanup; + } + nsm_req->data_len =3D cbor_string_length(pair[i].value); + } else { goto cleanup; } - str =3D cbor_bytestring_handle(pair[i].value); - if (!str) { - goto cleanup; - } - nsm_req->data_len =3D cbor_bytestring_length(pair[i].value); /* * nsm_req->data_len will be smaller than NSM_REQUEST_MAX_SIZE= as * we already check for the max request size before processing --=20 2.39.5