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 768291FF15C
	for <inbox@lore.proxmox.com>; Wed,  5 Mar 2025 16:35:54 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 9AA3919B96;
	Wed,  5 Mar 2025 16:35:48 +0100 (CET)
Message-ID: <2db917eb-875e-4dec-aa4d-42db882c50f2@proxmox.com>
Date: Wed, 5 Mar 2025 16:35:15 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Philipp Giersfeld <philipp.giersfeld@canarybit.eu>
References: <20250224123714.2662460-1-philipp.giersfeld@canarybit.eu>
 <20250224123714.2662460-4-philipp.giersfeld@canarybit.eu>
Content-Language: en-US
From: Fiona Ebner <f.ebner@proxmox.com>
In-Reply-To: <20250224123714.2662460-4-philipp.giersfeld@canarybit.eu>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.042 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [suse.com, cpuconfig.pm]
Subject: Re: [pve-devel] [PATCH qemu-server v3 3/5] 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>

Am 24.02.25 um 13:37 schrieb Philipp Giersfeld:
> Convert policy calcucalation to use shift operators and OR operation

Nit: there is a typo here: calcucalation

> instead of binary numbers and addition.
> 
> Signed-off-by: Philipp Giersfeld <philipp.giersfeld@canarybit.eu>
> Reviewed-by: Daniel Kral <d.kral@proxmox.com>
> Tested-by: Markus Frank <m.frank@proxmox.com>

With the typo above fixed:

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'});

While at it, we could also go for using constants, i.e. something like:
$policy |= AMD_SEV_POLICY_NO_DEBUG if $amd_sev_conf->{'no-debug'};
and for the one in the next patch, AMD_SEV_SNP_POLICY_NO_DEBUG.

But not a blocker from my side, if you don't want to go for it.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel