From patchwork Fri Dec 13 23:30:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 850293 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1778971wry; Fri, 13 Dec 2024 15:32:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVAaOTHAbjjIDttQZmR9yGIlhMbQfJC339VcmAUOkQBxATu7HfchdEsGSu/MiYA611bXud53Q==@linaro.org X-Google-Smtp-Source: AGHT+IFyAcQUwZEk+2ucYcvoOPKWJ/4um9xXQk7Fyq9zPTVGstJEZVIwE531HpY1gQX483naqwyw X-Received: by 2002:ac8:7f54:0:b0:467:6901:758b with SMTP id d75a77b69052e-467a570ec4fmr79805751cf.2.1734132745395; Fri, 13 Dec 2024 15:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734132745; cv=none; d=google.com; s=arc-20240605; b=JsTAZaGLj+hC5+jeC3KW8U+ecGcL9CQOy/NvbalCJO3b0Dma0YWqbJoRUj0G0QnIXn lNTEmjDE9EAgwj68imBY31EHlX2GwE5C92vT6rHHq1LPe0Yha6qRTQDBNQYa2RKXCzXf iKSnRtKVmXxW7lCLchUaSSqldtxrYtgiQNVJb3meA0b7lYi1IJ4j54wL4YC7JzW++x9j 2z8pPP2Hf94w20CLl2DqQrntYAFTW2Lon/iaycfo4sAgrAXP+M0BUzZ14k9Him6g59Fp tlyEuLZKeKV+g3taoMtoQHxDqpJGKJfdX8K0Qj+VWISpevyQH7/LSu2MjRwoZog3/NY4 hWYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BXfVV08MxsawwgxsL3+POkWX1t2O2SuGby8ORoVPva0=; fh=Z4bPwZROEtM93JvnC+9hAm/NXdUH8zoKsa9y7zDRVu4=; b=SIWdJV2Ur73YFBHNpf3BUK+vxhQg0+K+2RNn1qGD5YLr9dB5ECWWB9URpW/aXvqfsA ZMdEeTeXt1bZbNIBCnLWoiImq6R8bBkS5TYWiThUIWK5JNOouAkq6C+neuy6iM8a8U4f vwVaxKvKgwQAldSgQKpqIok62eCYUOCes0iaK2VW1XyKvl4W7u1FfYpbNcQ9wmPr5DFW j7OKgLOS40rav5E7HVJjvWdB7Nma3IbYoI1CWWOB55AnEFyZ4JVWxQUbpZmkKHoISHD+ 8focw6FxWvcnBREpaVEUhDkPn2s0A5F5dmTMx3XPhIOPh6VZdUYif0ZUPf0XtOdrDwtQ xKxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T/qZlnkE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b7047ee1f8si75673585a.181.2024.12.13.15.32.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Dec 2024 15:32:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T/qZlnkE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMF85-0002g7-2A; Fri, 13 Dec 2024 18:31:29 -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 1tMF7w-0002NZ-8U for qemu-devel@nongnu.org; Fri, 13 Dec 2024 18:31:23 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMF7t-0002zG-9u for qemu-devel@nongnu.org; Fri, 13 Dec 2024 18:31:19 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso15177315e9.3 for ; Fri, 13 Dec 2024 15:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734132675; x=1734737475; darn=nongnu.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=BXfVV08MxsawwgxsL3+POkWX1t2O2SuGby8ORoVPva0=; b=T/qZlnkE5CG9rk/oJsUX8UpcrkfMcdytcKmoty8voHcr/DQAC+Loi72Y/bdvBdlK8X 762B4UNL5CX0UB3aeYtDf33jPYZ8d/ykLBR2DpwtJC0ubbDoOHMeiUyFkUU05Aqxym0q IPURpETfGVdw1Og0M47TiPlvD2lp0WIYWTlztTIeZarvgvVgoVK9oZKVxHKob9de7zy9 pb2G9+UkfGhNcJG0Jwq/AkI4DMexX8oDCTeFesCXx+fsN5Xibc4ZDF6fA9yfnyhqHY6F u/8jtX+e75g9qeXHCKzmeKmZ5dZh5O48Y9IpPR/MWQUR6PxLB2PH8MtWBhoYucBELK8B f7vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734132675; x=1734737475; 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=BXfVV08MxsawwgxsL3+POkWX1t2O2SuGby8ORoVPva0=; b=dUlZgPMrNfMeXRqIalAl7b5V8sTN7zPxH0/AUzijyNkNMqN1qKgmj6TCjdjyJWr26n jWzhU2dRPjBqw7Ocnngf6TRKAedXvA3t9Bo3L2xNN3TdzuJhFtPt0y2ojhG4lCqTlJV1 mqlOdIs2GDB5n6Xnv9qd58kgD4keb8ofLD4UVfzy7lsIjjGJdbzxa+aPfQU/6FKCv2Og 8PKgv3isMZE+C5/1aKpAVjjS7GL/boYgapm7kcu4EYfYMdoZZ82UCkF12cJU1Go11DCk BvrcsPgSwmUT0PJQ+STtnblsSQ2MEvMLuR3hawnTK/DO8RdNdNtYQ53qOoOGk5lFEbHy BhiQ== X-Gm-Message-State: AOJu0Yyi9Yxx12cu2tugwIBPc0crehSzQ/vRG+jchJAZDB0JitaZ+b0Q Onvx+8UNsWN5MtgY8wuurqU1EoLtfpcTfrh3cLmh3xL7QWWiQ+3Yh8szq5gvdELf29RPoPS1G7F EyMs= X-Gm-Gg: ASbGnctNx27Dv749VuZ1ZAD2oUc2P6oPoKKWteQE7sMNfAk29ZE+hDAyrr5zgtJvrMi Vo2rbkpyK+rfvuM4Ex5yC+slKWsOWVVO/eo+Viqn5aYtJf4AvbT5pnXaeOqWnmQwFlJYX7410ja lVy+ymL2GGXmxnu5l5/+6pEg4k7c4i9vJ1WDaZW11nG4vZjkLWPj6DvZ979lKVW6jlkPuFljKiG GTh6gR+jPBuSnAZKaQzpJhWmc0Fgc0HIQwO7rUBJd8XwYkLLkplem8MU1oUFNwbIHv8MushNmfN j2ovnQ== X-Received: by 2002:a05:600c:4e4e:b0:436:1be4:c9b4 with SMTP id 5b1f17b1804b1-4362aaa83c6mr37739125e9.27.1734132675274; Fri, 13 Dec 2024 15:31:15 -0800 (PST) Received: from localhost.localdomain ([45.93.146.194]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436360154absm7313825e9.2.2024.12.13.15.31.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Dec 2024 15:31:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Dorjoy Chowdhury , Alexander Graf , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 03/20] hw/virtio/virtio-nsm: Support string data for extendPCR Date: Sat, 14 Dec 2024 00:30:38 +0100 Message-ID: <20241213233055.39574-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213233055.39574-1-philmd@linaro.org> References: <20241213233055.39574-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dorjoy Chowdhury NSM device in AWS Nitro Enclaves supports extending with both bytestring and string data. Signed-off-by: Dorjoy Chowdhury Reviewed-by: Alexander Graf Message-ID: <20241109123208.24281-1-dorjoychy111@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- 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 a3db8eef3e4..6830fcfe17b 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 = String("index"), * value = Uint8(pcr), * key = String("data"), - * value = Byte_String(data), + * value = Byte_String(data) || String(data), * } * } * } @@ -504,14 +504,21 @@ static enum NSMResponseTypes get_nsm_extend_pcr_req(uint8_t *req, size_t len, if (cbor_string_length(pair[i].key) == 4 && memcmp(str, "data", 4) == 0) { - if (!cbor_isa_bytestring(pair[i].value)) { + if (cbor_isa_bytestring(pair[i].value)) { + str = cbor_bytestring_handle(pair[i].value); + if (!str) { + goto cleanup; + } + nsm_req->data_len = cbor_bytestring_length(pair[i].value); + } else if (cbor_isa_string(pair[i].value)) { + str = cbor_string_handle(pair[i].value); + if (!str) { + goto cleanup; + } + nsm_req->data_len = cbor_string_length(pair[i].value); + } else { goto cleanup; } - str = cbor_bytestring_handle(pair[i].value); - if (!str) { - goto cleanup; - } - nsm_req->data_len = 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