From nobody Fri Dec 27 03:02:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732820743; cv=none; d=zohomail.com; s=zohoarc; b=GGIRHpW22eaofwYVcODODzf0BHpLJDZFRs+kl2Mw6ZqZ/USAM5XigRa4L8AhCbnnxxUtcscfFJroNxkFTNo3huXt2f1t4EEMeN0KwEu09t70oZqyjMlFYPyz+2FxK9r8r8QDTwkkVtnZoLKv1lZu97Y+BcnqYRE70wLqqFY2QHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732820743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uSPAmZ5HAFl4FKfZ+Gw97zq4slJCEYHZjBM9sewyH6k=; b=TXUYGSa846ZOiCltAv5f/23m6/Q1UkIs+TWy/kuIwlPw9bRgc7Ztn8r1IcGwysJayk7YEy2lx7ephSov/MU2d8kQkKPlIXhXWspT9EVuQWEYuzYXuND48ljboij/2AFse7HpZStjj9S2qLvGN3O0qX/TJiZPh6fY3mGAYBqISgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732820743865430.5620300389186; Thu, 28 Nov 2024 11:05:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGjoC-0007Th-3x; Thu, 28 Nov 2024 14:04:12 -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 1tGjo5-0007SA-WD for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGjo1-00012h-MZ for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:04 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-vCIspoTxOYq1JCP9qeOWFA-1; Thu, 28 Nov 2024 14:03:55 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-434941aa9c2so6445205e9.3 for ; Thu, 28 Nov 2024 11:03:55 -0800 (PST) Received: from [192.168.10.47] ([151.49.236.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434aa7e5285sm61508135e9.40.2024.11.28.11.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 11:03:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732820637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSPAmZ5HAFl4FKfZ+Gw97zq4slJCEYHZjBM9sewyH6k=; b=AuP/gobf/n8piYC5SykDNlHHlaqPd+7s6iyw/sE5Z9X8O0jmo7tLLEpjWCAF8XhGUz3xn7 2sEh0Igap6i2KY/luVgcW1c5utSf959LX7hklmGKhtAocxC0FYZioVykS3ASlRRV2FP4b0 6cM0AfwcCt1e09LfwTkCwb2btQY8vH0= X-MC-Unique: vCIspoTxOYq1JCP9qeOWFA-1 X-Mimecast-MFC-AGG-ID: vCIspoTxOYq1JCP9qeOWFA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732820634; x=1733425434; 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=uSPAmZ5HAFl4FKfZ+Gw97zq4slJCEYHZjBM9sewyH6k=; b=j5YFTqM9i8urA4evxFSh2dG1gq4OdZOTxB5t7msoFG9kdoXKHT46xQJEavvqrDUsWe HeoeX1IuOxA+d9akqVuDNPM7gQ19KwfRBk0vUKSdXm+WubPrxcUjckLhs5LYfjUAXL9E B3RWKfss0bEw697auctR6t2pEbgO+rUtBwHi2WWJ6Aay0Ydarmds+c3L/7y0zL8RpE+h 4/cmJt8jx/veBo3iSbpFs1YgwoJfzGzmAdSjVFXgPwLPsYo44WeZQCzJM6KDzPfh7V3I KQ965kjTkEgI0t0AZhXFUK+lABUea/ILU6nsS56nUgjl34LTCZ6WxDIa0pLky/jPfnLS iiBw== X-Gm-Message-State: AOJu0YxP1n7pHOVRHXHEWX9Qbj8tdYOsR82vHDeunCA5N+Jfj+0EIGaj /Rlu5JzgGBLMwouRL7gOtLfvjwCs17g+sHksEAr3jTRv945RWqvHkxcLRT7rHuTy4EK26zc94xJ 4x60sOHxA1me0ZxLRQAxaOH7WyioKpCLT0jOUlAqtr458y0LZ9KSmF1wb2uncG0gqpa4R4iS6en CykkPr98CqAyQUfITmZPXUJY1s9aQ9wfQgJ803 X-Gm-Gg: ASbGnctKKb3TezNO+CnCeGUSru3b34FRjXNXjVRGbwKxInKijsyS43qavFO85rRSmk8 A4VWA5NqeQ374eRhUjr9Tb/bn0PW6ekSShQRqffJcCA4KgimIZFqdvLi0q+vC6bthOijeyQYjpf vQa2lWzlufU7I9vELIX2PV/aNQCzPzMMtdAFg+UHlbuetyKkdGcVy1LqvvuKVG5nzQ3YPHIKzK9 ZOXfaU2PaSMu3SYIKHeucGSmgSsTbuL3O5m/atY1AphBjsuNr/AKMY= X-Received: by 2002:a05:600c:1f06:b0:431:2b66:44f7 with SMTP id 5b1f17b1804b1-434a9df7a8dmr86319155e9.31.1732820633817; Thu, 28 Nov 2024 11:03:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeu6LYj818VoSRBb5RO3+CNSbYGZS6F2+wkLZzdjDKiXwJyusKdOwn5rIV5gbAG2R/jAe5Ow== X-Received: by 2002:a05:600c:1f06:b0:431:2b66:44f7 with SMTP id 5b1f17b1804b1-434a9df7a8dmr86318825e9.31.1732820633437; Thu, 28 Nov 2024 11:03:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Sairaj Kodilkar , Santosh Shukla , Phil Dennis-Jordan Subject: [PULL 1/3] amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds Date: Thu, 28 Nov 2024 20:03:47 +0100 Message-ID: <20241128190349.541014-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241128190349.541014-1-pbonzini@redhat.com> References: <20241128190349.541014-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732820745814019100 Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Commit b12cb3819 (amd_iommu: Check APIC ID > 255 for XTSup) throws linking error for the `kvm_enable_x2apic` when kvm is disabled and Clang is used for compilation. This issue comes up because Clang does not remove the function callsite (kvm_enable_x2apic in this case) during optimization when if condition have variable. Intel IOMMU driver solves this issue by creating separate if condition for checking variables, which causes call site being optimized away by virtue of `kvm_irqchip_is_split()` being defined as 0. Implement same solution for the AMD driver. Fixes: b12cb3819baf (amd_iommu: Check APIC ID > 255 for XTSup) Signed-off-by: Sairaj Kodilkar Signed-off-by: Santosh Shukla Tested-by: Phil Dennis-Jordan Link: https://lore.kernel.org/r/20241114114509.15350-1-sarunkod@amd.com Signed-off-by: Paolo Bonzini --- hw/i386/amd_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 13af7211e11..af0f4da1f69 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1657,9 +1657,11 @@ static void amdvi_sysbus_realize(DeviceState *dev, E= rror **errp) error_report("AMD IOMMU with x2APIC confguration requires xtsup=3D= on"); exit(EXIT_FAILURE); } - if (s->xtsup && kvm_irqchip_is_split() && !kvm_enable_x2apic()) { - error_report("AMD IOMMU xtsup=3Don requires support on the KVM sid= e"); - exit(EXIT_FAILURE); + if (s->xtsup) { + if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) { + error_report("AMD IOMMU xtsup=3Don requires support on the KVM= side"); + exit(EXIT_FAILURE); + } } =20 pci_setup_iommu(bus, &amdvi_iommu_ops, s); --=20 2.47.0 From nobody Fri Dec 27 03:02:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732820743; cv=none; d=zohomail.com; s=zohoarc; b=SuwpY/uY8/Cv3LFag7W+esE2AdAxeKIDicgL82ltpfM/m1BbaMoKnT8Yl06/TyzXIyZmXToQuHCAQtyGXPprIuWu8+Qd/CcYfaU/AohbLob+thQlQzd5fQxjfsl5jxeM3YK/vRG7ifAYoh8iBFr99Un5eLyxzmQWElLxM8WerdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732820743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=46P5fCc+o6hH7ZVFiMBoQudmq3399lviu/5ndRrwzBo=; b=A0AGkSYTUaRfXEzY4shFzGRV03/5lCYgDILH8NKa9fT3wbkPFPDIrYw5/vOZS0Uhff6W2+PG144aTb715+ev9beF5GPb1YJCA6oKeGlH9kLSfyCc6lC+K3qybDCAHXt2coV8i7OFSf93ZJ1Yxuda5Y0kbMiXR3XGR0hECdDaFLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732820743874528.9294634309048; Thu, 28 Nov 2024 11:05:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGjoC-0007U7-Gf; Thu, 28 Nov 2024 14:04:12 -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 1tGjo4-0007RG-1S for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGjo1-00013R-AZ for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:03 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-p0_k8p6INoG8bGKn2L_aOQ-1; Thu, 28 Nov 2024 14:03:58 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-434a876d15cso11565235e9.0 for ; Thu, 28 Nov 2024 11:03:58 -0800 (PST) Received: from [192.168.10.47] ([151.49.236.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434b0dc6831sm30003565e9.20.2024.11.28.11.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 11:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732820639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=46P5fCc+o6hH7ZVFiMBoQudmq3399lviu/5ndRrwzBo=; b=KXJaSC9r5vGCZjjNtmE+CKWzph8fAR3AFwF8jRoHcdUPr4G/LEdpdo+Zcu/uYsqa6I4JSN bv/HhmCqBeTyNIDwYUrg/wo7ttc/QQG4T3s8+ZTrE6ql3i1o7PS6QTOiGPvaDPEe53bI2M C5+UcbZF4nzPyrDPCi3g1us8mwESD9w= X-MC-Unique: p0_k8p6INoG8bGKn2L_aOQ-1 X-Mimecast-MFC-AGG-ID: p0_k8p6INoG8bGKn2L_aOQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732820636; x=1733425436; 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=46P5fCc+o6hH7ZVFiMBoQudmq3399lviu/5ndRrwzBo=; b=pT+TqSxd1A1YyJ5l11KWPfrsL6v3mrsT3sM/KSlOqPolbL7dzJ8e4JnBKWFslwDd9D didJw8SyluXGn42RDn9LfQwjC0C74dgw8eWBQWHnFM0o4eUfpLSa9lnFoUJAlCHb54z7 hWVxjJldTjQ3g38RDWQ81Nd/pSzznVYPsS2NyZ5Ymz9OXH71aBERZRiWciHCUcUW5sSp GuTrC86aknCCmYV4/PNpODor5XoOi7DiM8VoP9wDQvrlHZlwR0EV0p5pfdRiJbfEFdb6 Nnx3EScUsspnnWPlHQ/1EvT7Pj5xyouWm5mLZW7p1Yd1O7aK9a99k7YHFIljNy9JYXN4 2yGg== X-Gm-Message-State: AOJu0YwSZD7lG4pI9iapP6z0L/LbPVlqzrUGP0JNahMPPpHcLkqHfWLP 29IS9cnEJPy/RiIgMfijKbsrM841NtuS2GcEtrH/Fb51b6V1dEO7el1hF6B1w5IaMwUHnVeDNB7 iyKXnlwTmh7nzSlMwRMqmGluLY3A29mgkw0pOJAlwXsbBY8EEx1ToCP9Cco98I6cV47mhJEsJkL gIrSjs/ik6umrFzafLOm9zt6fqCKtUmLOJgwO1 X-Gm-Gg: ASbGncvvFMs0ivAwT8Ij4MTxYmgUJqFvlpCdjyqSvzSxy2XoGXND2jKyrBzpjfaT3eV H/itNaEs/O447cJgmXh98iUaBIRA+7pHarKMPiXtfZTyQcizOACFVfu5gYtXTzo4KNjIVB+UxH/ YqYdMqvQ8nfh9nl8SEMbTz7W1GjnF1zhntAXf86H1gNk3Omeg4ZWhHro+NufKAFayhpuYa9C6zn KanZlFo54mXBhSyVU89x/HyR3MqvRdILwzWXqCHhQ8mRJpVBSsRGqk= X-Received: by 2002:a05:600c:1c0a:b0:434:9fca:d6c3 with SMTP id 5b1f17b1804b1-434afb9efa7mr36440855e9.9.1732820636431; Thu, 28 Nov 2024 11:03:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcIQhAjRqi1hRvhTolooHgF97VGizS/qP5LafGKxgrVGBnHyDwMQRN59plKOBPByk8tMX3oQ== X-Received: by 2002:a05:600c:1c0a:b0:434:9fca:d6c3 with SMTP id 5b1f17b1804b1-434afb9efa7mr36440205e9.9.1732820635502; Thu, 28 Nov 2024 11:03:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alexander Graf , Akihiro Suda , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Phil Dennis-Jordan Subject: [PULL 2/3] hvf: complete 1G page support Date: Thu, 28 Nov 2024 20:03:48 +0100 Message-ID: <20241128190349.541014-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241128190349.541014-1-pbonzini@redhat.com> References: <20241128190349.541014-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732820745857019100 From: Alexander Graf Hvf on x86 only supported 2MiB large pages, but never bothered to strip out the 1GiB page size capability from -cpu host. With QEMU 8.0.0 this became a problem because OVMF started to use 1GiB pages by default. Let's just unconditionally add 1GiB page walk support to the walker. With this fix applied, I can successfully run OVMF again. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1603 Signed-off-by: Alexander Graf Reported-by: Akihiro Suda Reported-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Phil Dennis-Jordan Link: https://lore.kernel.org/r/20230420225258.58009-1-agraf@csgraf.de Signed-off-by: Paolo Bonzini --- target/i386/hvf/x86_mmu.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/target/i386/hvf/x86_mmu.c b/target/i386/hvf/x86_mmu.c index 649074a7d24..579d0c3a4cc 100644 --- a/target/i386/hvf/x86_mmu.c +++ b/target/i386/hvf/x86_mmu.c @@ -38,6 +38,7 @@ #define LEGACY_PTE_PAGE_MASK (0xffffffffllu << 12) #define PAE_PTE_PAGE_MASK ((-1llu << 12) & ((1llu << 52) - 1)) #define PAE_PTE_LARGE_PAGE_MASK ((-1llu << (21)) & ((1llu << 52) - 1)) +#define PAE_PTE_SUPER_PAGE_MASK ((-1llu << (30)) & ((1llu << 52) - 1)) =20 struct gpt_translation { target_ulong gva; @@ -96,7 +97,7 @@ static bool get_pt_entry(CPUState *cpu, struct gpt_transl= ation *pt, =20 /* test page table entry */ static bool test_pt_entry(CPUState *cpu, struct gpt_translation *pt, - int level, bool *is_large, bool pae) + int level, int *largeness, bool pae) { uint64_t pte =3D pt->pte[level]; =20 @@ -118,9 +119,9 @@ static bool test_pt_entry(CPUState *cpu, struct gpt_tra= nslation *pt, goto exit; } =20 - if (1 =3D=3D level && pte_large_page(pte)) { + if (level && pte_large_page(pte)) { pt->err_code |=3D MMU_PAGE_PT; - *is_large =3D true; + *largeness =3D level; } if (!level) { pt->err_code |=3D MMU_PAGE_PT; @@ -152,9 +153,18 @@ static inline uint64_t pse_pte_to_page(uint64_t pte) return ((pte & 0x1fe000) << 19) | (pte & 0xffc00000); } =20 -static inline uint64_t large_page_gpa(struct gpt_translation *pt, bool pae) +static inline uint64_t large_page_gpa(struct gpt_translation *pt, bool pae, + int largeness) { - VM_PANIC_ON(!pte_large_page(pt->pte[1])) + VM_PANIC_ON(!pte_large_page(pt->pte[largeness])) + + /* 1Gib large page */ + if (pae && largeness =3D=3D 2) { + return (pt->pte[2] & PAE_PTE_SUPER_PAGE_MASK) | (pt->gva & 0x3ffff= fff); + } + + VM_PANIC_ON(largeness !=3D 1) + /* 2Mb large page */ if (pae) { return (pt->pte[1] & PAE_PTE_LARGE_PAGE_MASK) | (pt->gva & 0x1ffff= f); @@ -170,7 +180,7 @@ static bool walk_gpt(CPUState *cpu, target_ulong addr, = int err_code, struct gpt_translation *pt, bool pae) { int top_level, level; - bool is_large =3D false; + int largeness =3D 0; target_ulong cr3 =3D rvmcs(cpu->accel->fd, VMCS_GUEST_CR3); uint64_t page_mask =3D pae ? PAE_PTE_PAGE_MASK : LEGACY_PTE_PAGE_MASK; =20 @@ -186,19 +196,19 @@ static bool walk_gpt(CPUState *cpu, target_ulong addr= , int err_code, for (level =3D top_level; level > 0; level--) { get_pt_entry(cpu, pt, level, pae); =20 - if (!test_pt_entry(cpu, pt, level - 1, &is_large, pae)) { + if (!test_pt_entry(cpu, pt, level - 1, &largeness, pae)) { return false; } =20 - if (is_large) { + if (largeness) { break; } } =20 - if (!is_large) { + if (!largeness) { pt->gpa =3D (pt->pte[0] & page_mask) | (pt->gva & 0xfff); } else { - pt->gpa =3D large_page_gpa(pt, pae); + pt->gpa =3D large_page_gpa(pt, pae, largeness); } =20 return true; --=20 2.47.0 From nobody Fri Dec 27 03:02:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732820743; cv=none; d=zohomail.com; s=zohoarc; b=YcHLr7PjPAb1IC9CNQli7AM8kPcZ+7qljZp4fjK+YHrNEa2c8cbzMuZRUFqLKs37UzluK1+dOpzpk7hAuJ30zlAmUSzz35DbAoy86P+tzrMlf4B2zZ1tHOkE4HW7++X0qOvRftkOx0VVDsSoBytVuXwWCDwMbYRSLcSsUJsGQQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732820743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DiAuo9+wcwyjELbBvX9cPcyNm6cXW718y3hyCUiqNXA=; b=fZLxSaVT44UmTYyKxKNN33DdS6HONx9e5z18dHQ7D1hOl0fpxMWdCCE4gFcS4jZ0ERp6/gPcfZkXUI7n0PNV8jVx7g9XGDfzEBGuasU1QaBLpcQyK/bM12XKHmPj+s4vG6y5VrTv71Hg5gANC4FdqViL74O0j46V7VMZHxK7IEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732820743875888.2551359884762; Thu, 28 Nov 2024 11:05:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGjoH-0007V8-Gf; Thu, 28 Nov 2024 14:04:21 -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 1tGjo8-0007T0-7R for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGjo3-00014j-P5 for qemu-devel@nongnu.org; Thu, 28 Nov 2024 14:04:06 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-Kz18RYt5Pu6luq37s5tIaw-1; Thu, 28 Nov 2024 14:04:00 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-385dc37cb3eso87949f8f.0 for ; Thu, 28 Nov 2024 11:04:00 -0800 (PST) Received: from [192.168.10.47] ([151.49.236.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-385ccd3690dsm2316944f8f.35.2024.11.28.11.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 11:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732820642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DiAuo9+wcwyjELbBvX9cPcyNm6cXW718y3hyCUiqNXA=; b=NTWuHkdsF+udxQlxI2C4/kkHvfFCFfpUNKY6ssEIYPdvyi5WxX9J3u8+mv4gKFA58cHkG8 pB+7PzpBkku9G5WzuLXlmILo9/oP9qPLft4KiOonrm2v/A0ZIaUuLiw/Wx1e7h+jlyjhT8 fHuAjMfkWxbzDrPRYG2Rnu8LmQ9eKqo= X-MC-Unique: Kz18RYt5Pu6luq37s5tIaw-1 X-Mimecast-MFC-AGG-ID: Kz18RYt5Pu6luq37s5tIaw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732820638; x=1733425438; 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=DiAuo9+wcwyjELbBvX9cPcyNm6cXW718y3hyCUiqNXA=; b=CwKh4xtH2vSDx9Zy0+gJrqtaECBiTd0diO/RdF+0xdGNFTQwzVBQukkRaVnxfAHcUF NiLixCSewK7kw76gE7DLOl5gfT8TNJkueTnZw+njqlY0yCkYzuPVMi3alg+wHJS5Vlff d3r7dV8iwQipFu8xgx/BA+D0ubha11fl2K8AH8W2FfHYOtnaoDG4BVjo7FMUSVPQXIme qdEk2zWk+zOCs3+fCLTjIGd5hKj4GZJCCSo8Ikq5DEXFQ32vKZNhEewiOSoEAJpmgsVe uVFgVFsOfbjM7htIu94v34U7ajV2cNekEHq3OwTcQzckd3J2tmtzLmGRZy6CFFudNGjO WpPQ== X-Gm-Message-State: AOJu0Yxuwvc/T1wuSoTrcKI8dzh5wuXMFM2Nt5nPZZHSp3wNxbaR/lPj coJw095aIWx/QWLyLVm5HSM5OtimodjOf4PBEU3zA+V08uqmeKpv07wvmkzgQX92wtoQYPJnxbG Me/6VpKIr1v4j0c0Huf6q4MvFtWKhPTdvvGBKIaOgRrwpT+HJmufAzsktI/a2XjtMfqTwucEdb5 sdu09a84UZFeGtj29C9YHBBvs/22ItzPNdlge6 X-Gm-Gg: ASbGncvuQKz3Nef0mYKXkPVFH30DAmwi8q0E+T0DjhFwx0igeD+LcYRi1On78aalqb/ zGrzrijdmtE2p4kV1F4CYaa6bFmMMM+/ZUMV/z+fHvFLDwrWdGryoeqlcsptCPhhM/nzkQ1wwBG 0z5NydC5FqafaH6VYX0vCNnAYHgA4+dEwONegOehKeJ8U5muL6i5/dX605/tR1zj2SR6Ff4BqdO 1iYblQT7nxiOA7MQURFsDN4nu3Yir61I8PuudhDN1uwuUwqQnCgPBc= X-Received: by 2002:a5d:64ac:0:b0:382:4421:811a with SMTP id ffacd0b85a97d-385c6ef3978mr6899122f8f.49.1732820638630; Thu, 28 Nov 2024 11:03:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFe4vlitL7OyaXrAhfVGYjuVUBrA3iM7RWhR3APnmitCGqK52qW8/BVP3bMq8qqJWA5j7KZBg== X-Received: by 2002:a5d:64ac:0:b0:382:4421:811a with SMTP id ffacd0b85a97d-385c6ef3978mr6899086f8f.49.1732820638233; Thu, 28 Nov 2024 11:03:58 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Guenter Roeck , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fiona Ebner , qemu-stable@nongnu.org Subject: [PULL 3/3] scsi: megasas: Internal cdbs have 16-byte length Date: Thu, 28 Nov 2024 20:03:49 +0100 Message-ID: <20241128190349.541014-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241128190349.541014-1-pbonzini@redhat.com> References: <20241128190349.541014-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732820745890019100 From: Guenter Roeck Host drivers do not necessarily set cdb_len in megasas io commands. With commits 6d1511cea0 ("scsi: Reject commands if the CDB length exceeds buf_len") and fe9d8927e2 ("scsi: Add buf_len parameter to scsi_req_new()"), this results in failures to boot Linux from affected SCSI drives because cdb_len is set to 0 by the host driver. Set the cdb length to its actual size to solve the problem. Signed-off-by: Guenter Roeck Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Fiona Ebner Link: https://lore.kernel.org/r/20230228171129.4094709-1-linux@roeck-us.net Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 221b06d6aaf..b33229d71a4 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -1781,7 +1781,7 @@ static int megasas_handle_io(MegasasState *s, Megasas= Cmd *cmd, int frame_cmd) uint8_t cdb[16]; int len; struct SCSIDevice *sdev =3D NULL; - int target_id, lun_id, cdb_len; + int target_id, lun_id; =20 lba_count =3D le32_to_cpu(cmd->frame->io.header.data_len); lba_start_lo =3D le32_to_cpu(cmd->frame->io.lba_lo); @@ -1790,7 +1790,6 @@ static int megasas_handle_io(MegasasState *s, Megasas= Cmd *cmd, int frame_cmd) =20 target_id =3D cmd->frame->header.target_id; lun_id =3D cmd->frame->header.lun_id; - cdb_len =3D cmd->frame->header.cdb_len; =20 if (target_id < MFI_MAX_LD && lun_id =3D=3D 0) { sdev =3D scsi_device_find(&s->bus, 0, target_id, lun_id); @@ -1805,15 +1804,6 @@ static int megasas_handle_io(MegasasState *s, Megasa= sCmd *cmd, int frame_cmd) return MFI_STAT_DEVICE_NOT_FOUND; } =20 - if (cdb_len > 16) { - trace_megasas_scsi_invalid_cdb_len( - mfi_frame_desc(frame_cmd), 1, target_id, lun_id, cdb_len); - megasas_write_sense(cmd, SENSE_CODE(INVALID_OPCODE)); - cmd->frame->header.scsi_status =3D CHECK_CONDITION; - s->event_count++; - return MFI_STAT_SCSI_DONE_WITH_ERROR; - } - cmd->iov_size =3D lba_count * sdev->blocksize; if (megasas_map_sgl(s, cmd, &cmd->frame->io.sgl)) { megasas_write_sense(cmd, SENSE_CODE(TARGET_FAILURE)); @@ -1824,7 +1814,7 @@ static int megasas_handle_io(MegasasState *s, Megasas= Cmd *cmd, int frame_cmd) =20 megasas_encode_lba(cdb, lba_start, lba_count, is_write); cmd->req =3D scsi_req_new(sdev, cmd->index, - lun_id, cdb, cdb_len, cmd); + lun_id, cdb, sizeof(cdb), cmd); if (!cmd->req) { trace_megasas_scsi_req_alloc_failed( mfi_frame_desc(frame_cmd), target_id, lun_id); --=20 2.47.0