From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 34D0E1FF16E for <inbox@lore.proxmox.com>; Mon, 31 Mar 2025 16:00:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5F22078BB; Mon, 31 Mar 2025 16:00:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1743429592; x=1744034392; d=canarybit.eu; s=rsa2; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=3z/hAn+gAV2hOWQvEVqpmQc8JOtBbxn/KAi7fqNJBKw=; b=Ukyr1bAlSOxzjr6MB/faRtTbh5tntI1fbPE4zT6hHpS0AeyLVUNqYUQA21ss/vDyfZSbvVYJD1tG4 tpxIlxbPJsUCRuwB9zFjmJTkoYSQszxTgHtizX4fqBRYeQcu63E89G6RtAF9oveV6HHKP/1Gr/g3rU 07E32Rp1rBlK5iEZWUU/xgKnroeTk8VQxsbcr3Z6Pxl9oxFvnTptFamPQLSA1t56akihALWZl5tER2 vRXP8r/CRufUhfniVsAGGTKUUDg33f1T0YhIy0+3VrA3gw/WF5jmCKa0grZ2Mr7tryyhCa4CyQMRqd vy5iCYjpVNwur3k++HZsdp9vzlTiF2g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1743429592; x=1744034392; d=canarybit.eu; s=ed2; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=3z/hAn+gAV2hOWQvEVqpmQc8JOtBbxn/KAi7fqNJBKw=; b=G9x95GTUcuadH94OMohG//c7fdfHPFityVlheyCLBF1hvpuboRzkkWddxoUgDGztDoWXnbH8PPiWH AHzRNh2Ag== X-HalOne-ID: 6abad9be-0e38-11f0-bd49-2b8368a4d5c5 From: Philipp Giersfeld <philipp.giersfeld@canarybit.eu> To: pve-devel@lists.proxmox.com Date: Mon, 31 Mar 2025 15:59:29 +0200 Message-Id: <20250331135931.50568-3-philipp.giersfeld@canarybit.eu> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331135931.50568-1-philipp.giersfeld@canarybit.eu> References: <20250331135931.50568-1-philipp.giersfeld@canarybit.eu> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.126 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_MISSING 0.1 Missing DMARC policy RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH qemu-server v5 2/4] Convert policy calculation X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Convert policy calculation to use shift operators and OR operation instead of binary numbers and addition. Signed-off-by: Philipp Giersfeld <philipp.giersfeld@canarybit.eu> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com> --- no changes since last version PVE/QemuServer/CPUConfig.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm index e65d8c26..ad0be16e 100644 --- a/PVE/QemuServer/CPUConfig.pm +++ b/PVE/QemuServer/CPUConfig.pm @@ -846,12 +846,12 @@ sub get_amd_sev_object { # guest policy bit calculation as described here: # https://documentation.suse.com/sles/15-SP5/html/SLES-amd-sev/article-amd-sev.html#table-guestpolicy - my $policy = 0b0000; - $policy += 0b0001 if $amd_sev_conf->{'no-debug'}; - $policy += 0b0010 if $amd_sev_conf->{'no-key-sharing'}; - $policy += 0b0100 if $amd_sev_conf->{type} eq 'es'; + my $policy = 0; + $policy |= 1 << 0 if $amd_sev_conf->{'no-debug'}; + $policy |= 1 << 1 if $amd_sev_conf->{'no-key-sharing'}; + $policy |= 1 << 2 if $amd_sev_conf->{type} eq 'es'; # disable migration with bit 3 nosend to prevent amd-sev-migration-attack - $policy += 0b1000; + $policy |= 1 << 3; $sev_mem_object .= ',policy='.sprintf("%#x", $policy); $sev_mem_object .= ',kernel-hashes=on' if ($amd_sev_conf->{'kernel-hashes'}); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel