From patchwork Mon Aug 5 14:17:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13753671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90B6EC3DA4A for ; Mon, 5 Aug 2024 14:17:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.772212.1182648 (Exim 4.92) (envelope-from ) id 1sayWk-0001PZ-Pw; Mon, 05 Aug 2024 14:17:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 772212.1182648; Mon, 05 Aug 2024 14:17:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sayWk-0001PS-NQ; Mon, 05 Aug 2024 14:17:34 +0000 Received: by outflank-mailman (input) for mailman id 772212; Mon, 05 Aug 2024 14:17:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sayWj-0001PI-BG for xen-devel@lists.xenproject.org; Mon, 05 Aug 2024 14:17:33 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7471c344-5335-11ef-bc03-fd08da9f4363; Mon, 05 Aug 2024 16:17:32 +0200 (CEST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52f025ab3a7so14506380e87.2 for ; Mon, 05 Aug 2024 07:17:32 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bb884cddf4sm1743439a12.66.2024.08.05.07.17.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 07:17:31 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7471c344-5335-11ef-bc03-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1722867452; x=1723472252; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=Ko0MflhDQ7BonKM2X6psyr3vzTTfAWLWr063r7rjalE=; b=bLzb3HDc6omFkz6yhZYT6W5QRMHs2Xpf7Th3ID1ZJbBSxiFN9lb/fsClBydK3MtuCz NMgKvZMuoay1E4J25i2LkGjQBWkKJD9QHjWpvtfJ3VWZYlULIUyoFYOs28CQ27Cqr8DK Ku8C+6y36O+OQ2ybRz4wPQ+HRtRSh3O6gy2hV8qw87fp6hqLMciyhVTGsngqP1jdQlRa CUFEF4WgCR5Zz9f0zO34aBVFUkC3pAVKGg9Wjd/EEUvAM1uptPVU7BLiRnps6QiVb4XM r31jOkxMKPTJckIzcAScyx0NJKyKWdxrjMBOzez/zA8q4/ZBTjgdjTxnBdhNN6xUAt/Q 4Ygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722867452; x=1723472252; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ko0MflhDQ7BonKM2X6psyr3vzTTfAWLWr063r7rjalE=; b=hzWRAwv/eDnGTRjQNW4di4dokJ34HJd1lIXurss+sVjpZm2WD1UaLd7pOKHWgil9nH lsEGI61ZqPGwNKHUA0Zz1/DVCVD7WNaK9Xzda6S+hgoe8kUTxKNN85ywbgfrikapFlNK pfmxgTn7ownfMOB3n/Eu7P1jsbPNZETBN4y3FqvLlyKgL0y4zdYD7YHdxQ3+GQ7Jla/N G3jNpaZF7eC1TFIeqpzCKiMcdxAtIdwQ8c/FGrdRXcvYVb7LQ7hhpQ54VKYXQSPWdxqy hcYJ6fVzaMgxMB5k8km6boc5zgrvRg/oRDVSMYO1fSwo/z+oFcdi8q12omu8gMqtf3ZK m8wA== X-Gm-Message-State: AOJu0YxVSUloNj8FIVToAm+5pcKd+wxpxs6PNB0UgvaLpH/M9ZacG6s8 wosXqWAd6Yyq3uxa+sFoJNwVnu9Qj072wIzYhHvVKtjGVJtaXEhpDgtRcJ3c+3I6E10cQDx7yRk = X-Google-Smtp-Source: AGHT+IECIBP0QQETPA9IIHORScdM1T8EjDgY23b2GplUj3HY//Qt8bdyb7o67Jm9hn0bLP1E+iQVPA== X-Received: by 2002:a05:6512:3d89:b0:52e:987f:cfe4 with SMTP id 2adb3069b0e04-530bb396e7amr7639320e87.30.1722867451623; Mon, 05 Aug 2024 07:17:31 -0700 (PDT) Message-ID: <20944ace-6fb8-4a70-82aa-4ed595d01e5e@suse.com> Date: Mon, 5 Aug 2024 16:17:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= From: Jan Beulich Subject: [PATCH] x86emul: adjust 2nd param of idiv_dbl() Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA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SMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL -LONG_MIN cannot be represented in a long and hence is UB, for being one larger than LONG_MAX. The caller passing an unsigned long and the 1st param also being (array of) unsigned long, change the 2nd param accordingly while adding the sole necessary cast. This was the original form of the function anyway. Fixes: 5644ce014223 ("x86emul: relax asm() constraints") Oss-fuzz: 70923 Signed-off-by: Jan Beulich Reviewed-by: Stefano Stabellini --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -607,9 +607,9 @@ static bool div_dbl(unsigned long u[2], * NB. We don't use idiv directly as it's moderately hard to work out * ahead of time whether it will #DE, which we cannot allow to happen. */ -static bool idiv_dbl(unsigned long u[2], long v) +static bool idiv_dbl(unsigned long u[2], unsigned long v) { - bool negu = (long)u[1] < 0, negv = v < 0; + bool negu = (long)u[1] < 0, negv = (long)v < 0; /* u = abs(u) */ if ( negu )