Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1087975lqp; Thu, 23 May 2024 08:38:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaWPG7TAHLUQOQamInc8Ebu/UF1YIoxmJhCnx4piLf9ne+MLjyJN9jkx60RIOAfzD8aqLqPI5RFW43fBbRVuTmPqYedlY7wGBYZYiprw== X-Google-Smtp-Source: AGHT+IGpUdvo/bJerZGIyiJS0nKxj2gHOLDjpl1YKTtD8H+wTPjFhAQ26ci8kM2zxJFv5a/8A1HI X-Received: by 2002:a17:903:2291:b0:1f3:4b2a:1ac8 with SMTP id d9443c01a7336-1f34b2a1ca5mr15800405ad.13.1716478692137; Thu, 23 May 2024 08:38:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716478692; cv=pass; d=google.com; s=arc-20160816; b=tnJC4XZsmPW7aP067WnoG7RykuTo0cIGD289BeUFmN19uPDriYNFfF40t7UQziSMq+ 9ZV9XShcBX6SsUbIuVO9ivsRrMNDfNfGkvCjjKaUC5CTlQCKW4xN06T4gfq7jYG5o8Xk CyFEdGvc/kwTKssMp1e5WKP9Z341A71MMtDZVSRVtfCgSO9WxoOilwBDLl1lglwY/WNy 2nnQA9LD34vVdM/O3zIIZtznNMyTEmV5MoqbvJn9wAbJGQhnK5dVk3V+ua3XyesGxlvR iwckK3zA4KR/y+xIym8Cfle6FPmz0PNpeHWfGMD5KfYWgbKRF8skIOGAnEpxNQS2/C5h EAmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=qDb430+CIQ85u0Ej/5d34NhAAWYKYgLxz+dFZEGGm10=; fh=EI2fAJGCKP5iqnWLFK6ziR3A2HTk2unkJKpY1SMU2j4=; b=xgVEONdb4lwSCd1mmUz5aMajSTzWApDJ+UcrOOvF7IUyaxS5IRrVx2VZkmKAip6YIo VlycolF7//HwTPbKzAvR2P4Tf8jv0uQXwLe/eNACi87dbOpyj/Sc7ZjM9ZyyraPjvz9I LhpXumGOtYPgql4yVdhj5hudH5lR2T1MLWNxWkgImZPfuzVTHmu1rYJ0K2sgCZOUDDxH C8xvriJ57a9Zxnhg9f1W8YYDHD7ap79fczvO0W6WkIDe3R6DhnJO4CapaHFUz4m5BG2u THjFS24ewhr3DMRzqEwGQbPpWjsadC9KbUDma6+FLT9bcfeLJtc/l09TZGOlcgG2VIg4 7Cqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jYTA96l2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187725-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f33ef99636si13708215ad.364.2024.05.23.08.38.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187725-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jYTA96l2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187725-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D362DB22B15 for ; Thu, 23 May 2024 15:37:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39F75171A5; Thu, 23 May 2024 15:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jYTA96l2" Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AED1513ACC; Thu, 23 May 2024 15:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716478632; cv=none; b=ZDZgYGW3ZK0VTZQ0/2q5yQS1bMD8AGoWvaWbfUGyKkZ5EQ5mzQzuNRlrdT+uhVAtt5ur//4EbLzInkUlGeOp7cvTCWH8y95cQwxusdVMubymRLglOCngBOUNqDhVhUXxu3Ss70SvpQqCvgrobaqsichhRdz3JgMFesrgBxoz3uA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716478632; c=relaxed/simple; bh=DAu0j9XaO+BHc2+KymxPQHl8SlC0N0yHcL/u9tksZGw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Sjdt7yUUuI5J7GexX32X5owZZbcZikCOKtFxFAEfgusfHcbckTNSQoqEFRwj4/7kWVq7sduMgLX8O1MRR7zmaAD3Xs3TWQq8OElwKMObaJ7cRsf5YB+mpEw+RaZ3mDPgAPSey+yUU4IiPOAMLOsTFpJLKZEHAl5vdGTYORM/V8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jYTA96l2; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4201986d60aso18318045e9.3; Thu, 23 May 2024 08:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716478629; x=1717083429; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qDb430+CIQ85u0Ej/5d34NhAAWYKYgLxz+dFZEGGm10=; b=jYTA96l2T/CxGeiVP1luTiCFNwk45Vqz7q+tFrNc6AqzKmYqdgMNgva6O7C4nxer2p hE3xUw2bvlzh61xNyyI5T/dM+ZpUSL5vLbcMzI9559/P/FMJyKQ7yEGIayZFyfG6SQLO z5uoAfAqwfJQfFrxh7SS52B6yo6tW6DzIdb1Cxxtdn2CYNcMXW2x/57SBJ6O6ozC5vfR m/3IJ8uTskLv9JPo1HtBXeTivZU7gUOE9RFKQQBuFj4J6krHa6Splex0KxWqVVwFdhtL 26SLr+MvwSM9yzfglSBNrt5GqfGHb1+aa7vl82bZaAJfHYC9K9nlkmtkl4AZ1HGzxh63 3kiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716478629; x=1717083429; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qDb430+CIQ85u0Ej/5d34NhAAWYKYgLxz+dFZEGGm10=; b=lQABQIc+byIcBwUOc016iHuP1ns4SrcR0337n1algVcYYjpniwJbwBAhHxytqkMhwx d1WJ4Qe+zMMzBxabxxlKlxB+CpltNirPSqWfPqx8PLQ+cMquHSBvWnD7Z7+QcBtQCVKC LoW0uGqOIO/jif93g3HEglHYQUXjREioZfmF/PnTQ7irOsSZsflHtVQBDULAhkuJ0gcG EfMMdzmUMD7g5C1EggdRH3MmsC7w+58EL5YmUDvsgU4dEoPwjx9MT4i8stSnvOEy1d74 vIIXfQpTQ7NX5z1Mlj3YPN4A/BEkWb0Zom3wgxho3U700DFASaoQDkDtsZUi7y5m2shQ 1GpA== X-Forwarded-Encrypted: i=1; AJvYcCUXi0ECp2TYrkM+OkoHMaENfpTwWa7Kj16PivVUGPqmrnG0bJjOmhQ/CryUqsOf6RkIuKONuY/RUZRYhLRUifvuYdEfUGyQ0ZDxrnJXWjlRGW1pmuml9Tqff21dZ3elyBmTBeX0HIV6i/U1mdK7OMJ8JTV+0LF6Yf6PlZ/QCFgzf73GIiLgBEBhBYmKDUbUf11LzntENpXhJZDO0s3y17N2ylW4 X-Gm-Message-State: AOJu0Yz/y/EDXK3tDQL6aQe2auORCn3YWfKrWARBta6HjPM7m1Zb8wOW V8HaCs428eI1JyF/JFyDHZh2iOwzdvudXhJLkWLK3aQVugVFTdRb X-Received: by 2002:a05:600c:35c3:b0:41f:dae4:e9b7 with SMTP id 5b1f17b1804b1-420fd349963mr31813365e9.40.1716478628647; Thu, 23 May 2024 08:37:08 -0700 (PDT) Received: from [192.168.0.101] (craw-09-b2-v4wan-169726-cust2117.vm24.cable.virginm.net. [92.238.24.70]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42100fb7fe1sm28045695e9.45.2024.05.23.08.37.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 May 2024 08:37:08 -0700 (PDT) Message-ID: <637ed8cb-4503-40eb-9731-eb56e6b1cd93@gmail.com> Date: Thu, 23 May 2024 16:37:07 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][next] selftests: kvm: fix shift of 32 bit unsigned int more than 32 bits To: Dan Carpenter Cc: Sean Christopherson , Paolo Bonzini , Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240523113802.2195703-1-colin.i.king@gmail.com> Content-Language: en-US From: "Colin King (gmail)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23/05/2024 16:35, Dan Carpenter wrote: > On Thu, May 23, 2024 at 12:38:02PM +0100, Colin Ian King wrote: >> Currrentl a 32 bit 1u value is being shifted more than 32 bits causing >> overflow and incorrect checking of bits 32-63. Fix this by using the >> BIT_ULL macro for shifting bits. >> >> Detected by cppcheck: >> sev_init2_tests.c:108:34: error: Shifting 32-bit value by 63 bits is >> undefined behaviour [shiftTooManyBits] >> >> Fixes: dfc083a181ba ("selftests: kvm: add tests for KVM_SEV_INIT2") >> Signed-off-by: Colin Ian King >> --- >> tools/testing/selftests/kvm/x86_64/sev_init2_tests.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c b/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c >> index 7a4a61be119b..ea09f7a06aa4 100644 >> --- a/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c >> +++ b/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c >> @@ -105,11 +105,11 @@ void test_features(uint32_t vm_type, uint64_t supported_features) >> int i; >> >> for (i = 0; i < 64; i++) { >> - if (!(supported_features & (1u << i))) >> + if (!(supported_features & BIT_ULL(i))) >> test_init2_invalid(vm_type, >> &(struct kvm_sev_init){ .vmsa_features = BIT_ULL(i) }, >> "unknown feature"); >> - else if (KNOWN_FEATURES & (1u << i)) >> + else if (KNOWN_FEATURES & BIT_ULL(u)) > ^ > Should be i. How does this build? :P good catch, I sent the wrong one :-( > > regards, > dan carpenter >