From nobody Sun May 19 11:31:05 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=1591905079; cv=none; d=zohomail.com; s=zohoarc; b=mLyQCVn25tZVmMin7b8vL8ZtiJH+xHztc+UOlN+iuyh0krRVIbWkwuTkXdzbtWAfZPLNeHs2ywyoWZJc4RT+r8lsLH0hM23oRQZW4e0sjFmtlf5x73hq2FLZNixCU76n7616O8MOpON7Tgz6MPEufzxFsZ48Hff1FInPMQ2xeUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905079; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zmvvk2TUZzoW34IK4IX2JCUHzVDf1ekb5o2RBZ/OgD8=; b=bGRKOBhVYoq5FGWQqaJPr8Uhs6FxlJGxZmNC17yPkJW6uVy5pVEP8CpHGU9drAtDLDMgTng04rME8Uh5n5OUSR2zoZYEkYdUCfqxd56esCL3jg030mXY2N+dUsq8tgUA5NgCsCOxlSKbKX2F9r54k/qwzzAhwgysys53nInUhL8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190507911760.19748713182253; Thu, 11 Jun 2020 12:51:19 -0700 (PDT) Received: from localhost ([::1]:34368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTEL-0007GV-Ng for importer@patchew.org; Thu, 11 Jun 2020 15:51:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8I-0007DR-Fa for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:02 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54321 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000ld-Qy for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-4XK3QQX1M2qRqAbViStqYw-1; Thu, 11 Jun 2020 15:44:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80BE91005512 for ; Thu, 11 Jun 2020 19:44:51 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27FD45EE0E; Thu, 11 Jun 2020 19:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904696; 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=Zmvvk2TUZzoW34IK4IX2JCUHzVDf1ekb5o2RBZ/OgD8=; b=Nq9rvy3q+5y/9KzzZqnhPVK+QFcMe7bBXuq5DSTbU1AKfxErfjNvKPONlZcIrrMMIszHX1 AdY9bjABUJf5C0aVcj0xwdb56H5AU47RaBppZWYNOY9coxvt21VTxUAzThu24enfdiqM2a r7SUlON78X25sItBv9Uvs80cNez2s4M= X-MC-Unique: 4XK3QQX1M2qRqAbViStqYw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 001/115] docker.py/build: support -t and -f arguments Date: Thu, 11 Jun 2020 15:42:55 -0400 Message-Id: <20200611194449.31468-2-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) The docker.py command line is subtly different from docker and podman's, in that the tag and Dockerfile are passed via positional arguments. Remove this gratuitous difference and just parse -f and -t. -f was previously used by --extra-files, only keep the long option. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- tests/docker/Makefile.include | 2 +- tests/docker/docker.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index ed46bd98eb..f32a95b488 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -55,7 +55,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker else docker-image-%: $(DOCKER_FILES_DIR)/%.docker $(call quiet-command,\ - $(DOCKER_SCRIPT) build qemu:$* $< \ + $(DOCKER_SCRIPT) build -t qemu:$* -f $< \ $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \ $(if $(NOUSER),,--add-current-user) \ $(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\ diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 5a9735db78..d96ccc9b19 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -392,16 +392,16 @@ class BuildCommand(SubCommand): help=3D"""Specify a binary that will be copied= to the container together with all its dependent libraries""") - parser.add_argument("--extra-files", "-f", nargs=3D'*', + parser.add_argument("--extra-files", nargs=3D'*', help=3D"""Specify files that will be copied in= the Docker image, fulfilling the ADD directive fro= m the Dockerfile""") parser.add_argument("--add-current-user", "-u", dest=3D"user", action=3D"store_true", help=3D"Add the current user to image's passwd= ") - parser.add_argument("tag", + parser.add_argument("-t", dest=3D"tag", help=3D"Image Tag") - parser.add_argument("dockerfile", + parser.add_argument("-f", dest=3D"dockerfile", help=3D"Dockerfile name") =20 def run(self, args, argv): --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591904932; cv=none; d=zohomail.com; s=zohoarc; b=O5c55m0JM8JR+j8TSaGi/0vHaHK4cghiJuMjiu84FSMheGvsb4VNMZC1JXhzbVR0e22B96cnE/bWBQeN0lNf//upkaMEP1FDFJ7aTKXsp815bWwOuDFStwj+LqwjO5i4dA6J2nTi85k5j1RC86FZiK/Xbza+OnFlbNzFn7ZFBpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591904932; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wucDS0WDxIJnY572b6MT723ttGMTngApmYMEbO/keOQ=; b=ktnkKdXNdZ288/DDzxLpc7QZDvd+4eDV2KnVd9QaNsH6f/sm7gsfty2kInsI98dPVhpPdMrcPTG5ONJnLP72fC3ZVlZRANrTS/kDkev3rjvncu8EoTjyVhXAvCiMfMIJwDBYz0z4i/uycd/YZiNJ3RX1DSEozr4nU0sHGF6QmDo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591904932271105.52745592272231; Thu, 11 Jun 2020 12:48:52 -0700 (PDT) Received: from localhost ([::1]:54036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTBy-0002nz-RR for importer@patchew.org; Thu, 11 Jun 2020 15:48:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8H-0007CU-B4 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:01 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44865 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000la-Ra for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-m8--x84JMI6-Gu2E76wGkA-1; Thu, 11 Jun 2020 15:44:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BF57A0C00 for ; Thu, 11 Jun 2020 19:44:52 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7A175EE0E; Thu, 11 Jun 2020 19:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904696; 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=wucDS0WDxIJnY572b6MT723ttGMTngApmYMEbO/keOQ=; b=E3bH486Fvq/dnPksZwaNG/qT9iax4tI6XSCNLCQxAmd723x1EqTXAzOfPndteyrhK42jMu lV+ANboYVwGvAEN1M0AQsCieu+9ZDCCB1CpaBW5OqO9c7tNIVXgK120RHYRoC/mJcmo2D3 /OmSQDwGV8xwnXRbX+4fA8c/eYAhdbE= X-MC-Unique: m8--x84JMI6-Gu2E76wGkA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 002/115] docker.py/build: support binary files in --extra-files Date: Thu, 11 Jun 2020 15:42:56 -0400 Message-Id: <20200611194449.31468-3-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Read the --extra-files in binary mode to avoid encoding errors. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- tests/docker/docker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index d96ccc9b19..e630aae108 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -56,15 +56,19 @@ class EngineEnum(enum.IntEnum): =20 USE_ENGINE =3D EngineEnum.AUTO =20 +def _bytes_checksum(bytes): + """Calculate a digest string unique to the text content""" + return hashlib.sha1(bytes).hexdigest() + def _text_checksum(text): """Calculate a digest string unique to the text content""" - return hashlib.sha1(text.encode('utf-8')).hexdigest() + return _bytes_checksum(text.encode('utf-8')) =20 def _read_dockerfile(path): return open(path, 'rt', encoding=3D'utf-8').read() =20 def _file_checksum(filename): - return _text_checksum(_read_dockerfile(filename)) + return _bytes_checksum(open(filename, 'rb').read()) =20 =20 def _guess_engine_command(): --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905228; cv=none; d=zohomail.com; s=zohoarc; b=YHI90hFBtpjDK42O0NHkK23KjmTj9x3+ftle2jJBhvo3Fi+pvVu0IFiSjvAFXpOERe7oZ54ytrjGQUmG4kU4N9y8U0Uw5Peg1hKtsCS2UUiJhOuwvOEjsP9vwyDCfpNwzVwqxl4XsGo/gBMXO4wG2rF380wDGoih18GpvOlnO8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905228; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tJrxybmGdrfBbB987Z3tJ0S0qgwtOuPu1SkhX8bjTVs=; b=aj/v+OZduD5LJNKxZOtey5bJ/SHZTPexB+LbpwDa1I/2GmWG7++xpzZoLzSjFuVlt4LCMjHDOh9H5PWcXk3kjCjnRr2aONR2z04lQlpv8FneV6Rp3W17ycP8IxON4YxxIEjoJwCpYjV/ceauB6DOJA7uDZWcJ8HnauV6iM+O5ug= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905228955172.188424016961; Thu, 11 Jun 2020 12:53:48 -0700 (PDT) Received: from localhost ([::1]:43034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTGl-00037q-6Q for importer@patchew.org; Thu, 11 Jun 2020 15:53:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8J-0007Fe-Un for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50367 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000lz-RD for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-YPubPvptM3etsUH0GYJGuQ-1; Thu, 11 Jun 2020 15:44:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B8CC1005513; Thu, 11 Jun 2020 19:44:52 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 328817E587; Thu, 11 Jun 2020 19:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904698; 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=tJrxybmGdrfBbB987Z3tJ0S0qgwtOuPu1SkhX8bjTVs=; b=egm/lZRIt4X+oRd6XAeR+V7CSSWjkiwsVOKSb0Y9zrmE9pZS84txwkTmyDfOjxTnlXJUFN hyzEnYN1weJpJq2XQXuBdA2j6omrJN4j3lx+CgrVG1s1b9zpVZ8v78OXz9+SM+x1aVQs21 leHOp/68FF/1crSRUmIavZ6gwpTwvG4= X-MC-Unique: YPubPvptM3etsUH0GYJGuQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 003/115] run-coverity-scan: get Coverity token and email from special git config section Date: Thu, 11 Jun 2020 15:42:57 -0400 Message-Id: <20200611194449.31468-4-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Support a [coverity] section in .git/config. It can be used to retrieve the token and also, if it is different from user.email, the username of the submitter. Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index 2e067ef5cf..990f75138d 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -41,9 +41,10 @@ # is intended mainly for internal use by the Docker supp= ort # # User-specifiable environment variables: -# COVERITY_TOKEN -- Coverity token +# COVERITY_TOKEN -- Coverity token (default: looks at your +# coverity.token config) # COVERITY_EMAIL -- the email address to use for uploads (default: -# looks at your git user.email config) +# looks at your git coverity.email or user.email config) # COVERITY_BUILD_CMD -- make command (default: 'make -jN' where N is # number of CPUs as determined by 'nproc') # COVERITY_TOOL_BASE -- set to directory to put coverity tools @@ -58,11 +59,11 @@ check_upload_permissions() { # with status 1 if the check failed (usually a bad token); # will exit the script with status 0 if the check indicated that we # can't upload yet (ie we are at quota) - # Assumes that PROJTOKEN, PROJNAME and DRYRUN have been initialized. + # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initializ= ed. =20 echo "Checking upload permissions..." =20 - if ! up_perm=3D"$(wget https://scan.coverity.com/api/upload_permitted = --post-data "token=3D$PROJTOKEN&project=3D$PROJNAME" -q -O -)"; then + if ! up_perm=3D"$(wget https://scan.coverity.com/api/upload_permitted = --post-data "token=3D$COVERITY_TOKEN&project=3D$PROJNAME" -q -O -)"; then echo "Coverity Scan API access denied: bad token?" exit 1 fi @@ -94,20 +95,20 @@ check_upload_permissions() { update_coverity_tools () { # Check for whether we need to download the Coverity tools # (either because we don't have a copy, or because it's out of date) - # Assumes that COVERITY_TOOL_BASE, PROJTOKEN and PROJNAME are set. + # Assumes that COVERITY_TOOL_BASE, COVERITY_TOKEN and PROJNAME are set. =20 mkdir -p "$COVERITY_TOOL_BASE" cd "$COVERITY_TOOL_BASE" =20 echo "Checking for new version of coverity build tools..." - wget https://scan.coverity.com/download/linux64 --post-data "token=3D$= PROJTOKEN&project=3D$PROJNAME&md5=3D1" -O coverity_tool.md5.new + wget https://scan.coverity.com/download/linux64 --post-data "token=3D$= COVERITY_TOKEN&project=3D$PROJNAME&md5=3D1" -O coverity_tool.md5.new =20 if ! cmp -s coverity_tool.md5 coverity_tool.md5.new; then # out of date md5 or no md5: download new build tool # blow away the old build tool echo "Downloading coverity build tools..." rm -rf coverity_tool coverity_tool.tgz - wget https://scan.coverity.com/download/linux64 --post-data "token= =3D$PROJTOKEN&project=3D$PROJNAME" -O coverity_tool.tgz + wget https://scan.coverity.com/download/linux64 --post-data "token= =3D$COVERITY_TOKEN&project=3D$PROJNAME" -O coverity_tool.tgz if ! (cat coverity_tool.md5.new; echo " coverity_tool.tgz") | md5= sum -c --status; then echo "Downloaded tarball didn't match md5sum!" exit 1 @@ -205,6 +206,9 @@ while [ "$#" -ge 1 ]; do esac done =20 +if [ -z "$COVERITY_TOKEN" ]; then + COVERITY_TOKEN=3D"$(git config coverity.token)" +fi if [ -z "$COVERITY_TOKEN" ]; then echo "COVERITY_TOKEN environment variable not set" exit 1 @@ -225,7 +229,6 @@ if [ -z "$SRCDIR" ]; then SRCDIR=3D"$PWD" fi =20 -PROJTOKEN=3D"$COVERITY_TOKEN" PROJNAME=3DQEMU TARBALL=3Dcov-int.tar.xz =20 @@ -268,6 +271,9 @@ if [ -z "$DESCRIPTION" ]; then DESCRIPTION=3D"$(git rev-parse HEAD)" fi =20 +if [ -z "$COVERITY_EMAIL" ]; then + COVERITY_EMAIL=3D"$(git config coverity.email)" +fi if [ -z "$COVERITY_EMAIL" ]; then COVERITY_EMAIL=3D"$(git config user.email)" fi @@ -393,7 +399,7 @@ if [ "$DRYRUN" =3D yes ]; then exit 0 fi =20 -curl --form token=3D"$PROJTOKEN" --form email=3D"$COVERITY_EMAIL" \ +curl --form token=3D"$COVERITY_TOKEN" --form email=3D"$COVERITY_EMAIL" \ --form file=3D@"$TARBALL" --form version=3D"$VERSION" \ --form description=3D"$DESCRIPTION" \ https://scan.coverity.com/builds?project=3D"$PROJNAME" --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591904853; cv=none; d=zohomail.com; s=zohoarc; b=ljbf+Mv43vWVMIyrcoBgiVYLy+Xubj+dMCyKBUEyERzmeCrVgeAxH+uf/9j/gxlI0SHyIUBEP8B3gEu6JaYnkuXkvHNOyevMo4PmO50cxrhzN6nfWtwa/YLflniXiZUf8hpr2wM2oVl/bQ2kRe/9w8iXufkcEmWAzL4D9SLy6ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591904853; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1x1449wh9fFr7gq1V8OCFbpQf1TKKB1YZGtB8zf4V7c=; b=UGPXCNTRANI2vK2a7qeJBwcR2I5ywNlcvAFri9nSBJHvCKV4CqQK9rTbh0xo6pu6UQnzJDc/bqLhKaQWW5cHym/Fz7Fa6dfA4u2Cp6J4uuuXBwT7ZQS/Vh/Ot5vcezO5Lx1B+TR80wL51lmFEa0NxI1buKrxxYAK33H4CVaJW6s= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591904853864193.0681786051873; Thu, 11 Jun 2020 12:47:33 -0700 (PDT) Received: from localhost ([::1]:51000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTAh-0001Hy-Rb for importer@patchew.org; Thu, 11 Jun 2020 15:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8H-0007Cf-Nj for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:01 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30027 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000li-RB for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-Shpqr4PROleL3WbBYnpWKg-1; Thu, 11 Jun 2020 15:44:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00FE9107ACCA for ; Thu, 11 Jun 2020 19:44:53 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1EE25EE0E for ; Thu, 11 Jun 2020 19:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1x1449wh9fFr7gq1V8OCFbpQf1TKKB1YZGtB8zf4V7c=; b=Bx9wU6JZO9qwyCOSpWBjdDoyGL8IV5Iad8ibLWdo9Jtmg2AwaoIjqdJOTVqC17fbvvaJA8 EO0WRZnqTBblb1Y9TtqHPZdNDobn0wOdpHKPuzGoILQaZMCZPcRenQTRzXqgYCaaUBEieH 86pmY9O0xeo84zvytwkyF9FpuZO9iAE= X-MC-Unique: Shpqr4PROleL3WbBYnpWKg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 004/115] run-coverity-scan: use docker.py Date: Thu, 11 Jun 2020 15:42:58 -0400 Message-Id: <20200611194449.31468-5-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Our trusted docker wrapper allows run-coverity-scan to run with both docker and podman. For the "run" phase this is transparent; for the "build" phase however scripts are replaced with a bind mount (-v). This is not an issue because the secret option is meant for secrets stored globally in the system and bind mounts are a valid substitute for secrets that are known to whoever builds the container. Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/coverity-scan.docker | 2 +- scripts/coverity-scan/run-coverity-scan | 32 ++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/scripts/coverity-scan/coverity-scan.docker b/scripts/coverity-= scan/coverity-scan.docker index a4f64d1283..6f0460b66c 100644 --- a/scripts/coverity-scan/coverity-scan.docker +++ b/scripts/coverity-scan/coverity-scan.docker @@ -128,4 +128,4 @@ RUN rpm -q $PACKAGES | sort > /packages.txt ENV PATH $PATH:/usr/libexec/python3-sphinx/ ENV COVERITY_TOOL_BASE=3D/coverity-tools COPY run-coverity-scan run-coverity-scan -RUN --mount=3Dtype=3Dsecret,id=3Dcoverity.token,required ./run-coverity-sc= an --update-tools-only --tokenfile /run/secrets/coverity.token +RUN ./run-coverity-scan --update-tools-only --tokenfile /work/token diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index 990f75138d..e926623b3b 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -29,7 +29,9 @@ =20 # Command line options: # --dry-run : run the tools, but don't actually do the upload -# --docker : create and work inside a docker container +# --docker : create and work inside a container +# --docker-engine : specify the container engine to use (docker/podman/a= uto); +# implies --docker # --update-tools-only : update the cached copy of the tools, but don't r= un them # --tokenfile : file to read Coverity token from # --version ver : specify version being analyzed (default: ask git) @@ -197,6 +199,17 @@ while [ "$#" -ge 1 ]; do ;; --docker) DOCKER=3Dyes + DOCKER_ENGINE=3Dauto + shift + ;; + --docker-engine) + shift + if [ $# -eq 0 ]; then + echo "--docker-engine needs an argument" + exit 1 + fi + DOCKER=3Dyes + DOCKER_ENGINE=3D"$1" shift ;; *) @@ -283,9 +296,8 @@ if [ "$DOCKER" =3D yes ]; then # build docker container including the coverity-scan tools # Put the Coverity token into a temporary file that only # we have read access to, and then pass it to docker build - # using --secret. This requires at least Docker 18.09. - # Mostly what we are trying to do here is ensure we don't leak - # the token into the Docker image. + # using a volume. A volume is enough for the token not to + # leak into the Docker image. umask 077 SECRETDIR=3D$(mktemp -d) if [ -z "$SECRETDIR" ]; then @@ -300,12 +312,10 @@ if [ "$DOCKER" =3D yes ]; then # TODO: This re-downloads the tools every time, rather than # caching and reusing the image produced with the downloaded tools. # Not sure why. - # TODO: how do you get 'docker build' to print the output of the - # commands it is running to its stdout? This would be useful for debug. - DOCKER_BUILDKIT=3D1 docker build -t coverity-scanner \ - --secret id=3Dcoverity.token,src=3D"$SECRET" \ - -f scripts/coverity-scan/coverity-scan.docker \ - scripts/coverity-scan + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coverity-s= can.docker \ + -v "$SECRETDIR:/work" \ + --extra-files scripts/coverity-scan/run-coverity-scan echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" if [ "$DRYRUN" =3D yes ]; then @@ -323,7 +333,7 @@ if [ "$DOCKER" =3D yes ]; then # Arrange for this docker run to get access to the sources with -v. # We pass through all the configuration from the outer script to the i= nner. export COVERITY_EMAIL COVERITY_BUILD_CMD - docker run -it --env COVERITY_EMAIL --env COVERITY_BUILD_CMD \ + tests/docker/docker.py run -it --env COVERITY_EMAIL --env COVERITY_BUI= LD_CMD \ -v "$SECRETDIR:/work" coverity-scanner \ ./run-coverity-scan --version "$VERSION" \ --description "$DESCRIPTION" $DRYRUNARG --tokenfile /work/token= \ --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905458; cv=none; d=zohomail.com; s=zohoarc; b=e0Huaaj7YkLEpNvnnZQ3Xjl5q4E5LPG7/YNyypQOmjPxdjFjIugVJj4PmREPruSQV5JjF5oC8Jy4LfXZrOf8nTAVZU+TGV48MAJ8/RzftJrV6L19myJoAKY4O8jRhFhATa1urW/Z+Yb24Bc9af1To61Dus2Qw4QEii29eLrWiV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nEfu+WKuLGTbcmW54phLurwiymXP59SyP07hImE7S0M=; b=Ln/1RvCE5t69P0hMTk9Oo8ZTUlg4EBhMZgGyy2QZrJR/I9pvLbfIf2gKlKhr+Hb44yln6IStFh12IaEcFH07ZkFzbisXQ6SmDPnu5Qc8Z7IRE7umyfMMfXEJ/ND6v5Qx3Aw8lg1frRvJN2XvNoVtQ6HEk0PVuUom8ljtmyEWvEA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190545834845.955556047384334; Thu, 11 Jun 2020 12:57:38 -0700 (PDT) Received: from localhost ([::1]:57000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTKS-0001dM-U8 for importer@patchew.org; Thu, 11 Jun 2020 15:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8i-0007ii-8Q for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:28 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:58498 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8f-0000ye-R6 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-WNYUUgg-OfCTuxpns4ZYZg-1; Thu, 11 Jun 2020 15:44:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8003584638E; Thu, 11 Jun 2020 19:44:53 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27AFC5EE0E; Thu, 11 Jun 2020 19:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904725; 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=nEfu+WKuLGTbcmW54phLurwiymXP59SyP07hImE7S0M=; b=WIn2ro1FvI5zpEXkpJBHRtUIm4mUteFpVlXGHCV7nj4+V1UtSqvdtSzigavCTgtcaPJgkB 7u8UEfbnV7gUus2IzapNmd2MVu25ZlXAyxPfkiWyUTUucilC1IK7YjMtJW8X40Vv3n7BrU pgjBvUu0LgWZLQ3AhhxXkc95WO76Qfo= X-MC-Unique: WNYUUgg-OfCTuxpns4ZYZg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 005/115] run-coverity-scan: add --no-update-tools option Date: Thu, 11 Jun 2020 15:42:59 -0400 Message-Id: <20200611194449.31468-6-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Provide a quick way to skip building the container while we figure out how to get caching right. Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 37 +++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index e926623b3b..bc9e12670b 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -33,6 +33,7 @@ # --docker-engine : specify the container engine to use (docker/podman/a= uto); # implies --docker # --update-tools-only : update the cached copy of the tools, but don't r= un them +# --no-update-tools : do not update the cached copy of the tools # --tokenfile : file to read Coverity token from # --version ver : specify version being analyzed (default: ask git) # --description desc : specify description of this version (default: ask= git) @@ -130,7 +131,7 @@ update_coverity_tools () { =20 # Check user-provided environment variables and arguments DRYRUN=3Dno -UPDATE_ONLY=3Dno +UPDATE=3Dyes DOCKER=3Dno =20 while [ "$#" -ge 1 ]; do @@ -139,9 +140,13 @@ while [ "$#" -ge 1 ]; do shift DRYRUN=3Dyes ;; + --no-update-tools) + shift + UPDATE=3Dno + ;; --update-tools-only) shift - UPDATE_ONLY=3Dyes + UPDATE=3Donly ;; --version) shift @@ -245,12 +250,12 @@ fi PROJNAME=3DQEMU TARBALL=3Dcov-int.tar.xz =20 -if [ "$UPDATE_ONLY" =3D yes ] && [ "$DOCKER" =3D yes ]; then +if [ "$UPDATE" =3D only ] && [ "$DOCKER" =3D yes ]; then echo "Combining --docker and --update-only is not supported" exit 1 fi =20 -if [ "$UPDATE_ONLY" =3D yes ]; then +if [ "$UPDATE" =3D only ]; then # Just do the tools update; we don't need to check whether # we are in a source tree or have upload rights for this, # so do it before some of the command line and source tree checks. @@ -293,7 +298,6 @@ fi =20 # Run ourselves inside docker if that's what the user wants if [ "$DOCKER" =3D yes ]; then - # build docker container including the coverity-scan tools # Put the Coverity token into a temporary file that only # we have read access to, and then pass it to docker build # using a volume. A volume is enough for the token not to @@ -308,14 +312,17 @@ if [ "$DOCKER" =3D yes ]; then echo "Created temporary directory $SECRETDIR" SECRET=3D"$SECRETDIR/token" echo "$COVERITY_TOKEN" > "$SECRET" - echo "Building docker container..." - # TODO: This re-downloads the tools every time, rather than - # caching and reusing the image produced with the downloaded tools. - # Not sure why. - tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ - -t coverity-scanner -f scripts/coverity-scan/coverity-s= can.docker \ - -v "$SECRETDIR:/work" \ - --extra-files scripts/coverity-scan/run-coverity-scan + if [ "$UPDATE" !=3D no ]; then + # build docker container including the coverity-scan tools + echo "Building docker container..." + # TODO: This re-downloads the tools every time, rather than + # caching and reusing the image produced with the downloaded tools. + # Not sure why. + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coveri= ty-scan.docker \ + -v "$SECRETDIR:/work" \ + --extra-files scripts/coverity-scan/run-coverity-sc= an + fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" if [ "$DRYRUN" =3D yes ]; then @@ -350,7 +357,9 @@ fi =20 check_upload_permissions =20 -update_coverity_tools +if [ "$UPDATE" !=3D no ]; then + update_coverity_tools +fi =20 TOOLBIN=3D"$(cd "$COVERITY_TOOL_BASE" && echo $PWD/coverity_tool/cov-analy= sis-*/bin)" =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905037; cv=none; d=zohomail.com; s=zohoarc; b=llr6uAtyABgnqgJ5ILWoB50UPqvMni4KfgRVTavmfgC5huvT3q9of58YRwLuc7UETN5FjM/J8EmiT0ZvhOjH1Diu+gesjyaPY+tC1aQTwC8N7EsFFO4rnwJDQ9ZFHcq/jYQdhIxYMEiiWbOzFlSv8Pes6C38KOjvSU/Exi/ohEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905037; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RYYQUL0ofIRC+VTkLDVn89vPvmwrazQpp2d5+kAvCAk=; b=SpBsyCpBt0k/va9NK0U098J5H8qB/Lv4H7mWLuivDZr2yhqw8hC3VUo0BFG7nNB2xWjEk4CjpQXgZ6tc7AV60rIl0nQA+goO7ploRbSCIPF5srXyDwzsIqPzL76iuhdCmSQO/Hv8cbtxArPuxXt2GnMlusjbUCBWd92L/F11VDo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905037759748.3204916014857; Thu, 11 Jun 2020 12:50:37 -0700 (PDT) Received: from localhost ([::1]:59846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTDg-00061c-DO for importer@patchew.org; Thu, 11 Jun 2020 15:50:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8J-0007Ed-6i for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:03 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:45777 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8F-0000mB-7F for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-6UqIN7VGO_O04JsTh9tdEw-1; Thu, 11 Jun 2020 15:44:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AD78107ACCD; Thu, 11 Jun 2020 19:44:54 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CE57E587; Thu, 11 Jun 2020 19:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904698; 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=RYYQUL0ofIRC+VTkLDVn89vPvmwrazQpp2d5+kAvCAk=; b=UF0EQ+KQkiwO/7kWE2MP9lrjfpbCPDIdifcETprfzwtZL3m+rpM9TNJYf9idUdsJ3ATTGO 1064PPnSnz9jlXZ9mmHGLJ+mUxOuhcu89UeV0LRQYd1qttvWAbGy/t/tCHM6e+swztw3Cn WiBJLLLoXAqYM2VbtWt3zEtzdmsjD4M= X-MC-Unique: 6UqIN7VGO_O04JsTh9tdEw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 006/115] run-coverity-scan: use --no-update-tools in docker run Date: Thu, 11 Jun 2020 15:43:00 -0400 Message-Id: <20200611194449.31468-7-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Tools are already updated via the docker build. Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index bc9e12670b..6bb38b4f48 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -325,17 +325,16 @@ if [ "$DOCKER" =3D yes ]; then fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" + ARGS=3D"--no-update-tools" if [ "$DRYRUN" =3D yes ]; then - DRYRUNARG=3D--dry-run + ARGS=3D"$ARGS --dry-run" fi echo "Running scanner..." # If we need to capture the output tarball, get the inner run to # save it to the secrets directory so we can copy it out before the # directory is cleaned up. if [ ! -z "$RESULTSTARBALL" ]; then - RTARGS=3D"--results-tarball /work/cov-int.tar.xz" - else - RTARGS=3D"" + ARGS=3D"$ARGS --results-tarball /work/cov-int.tar.xz" fi # Arrange for this docker run to get access to the sources with -v. # We pass through all the configuration from the outer script to the i= nner. @@ -343,8 +342,8 @@ if [ "$DOCKER" =3D yes ]; then tests/docker/docker.py run -it --env COVERITY_EMAIL --env COVERITY_BUI= LD_CMD \ -v "$SECRETDIR:/work" coverity-scanner \ ./run-coverity-scan --version "$VERSION" \ - --description "$DESCRIPTION" $DRYRUNARG --tokenfile /work/token= \ - --srcdir /qemu --src-tarball /work/qemu-sources.tgz $RTARGS + --description "$DESCRIPTION" $ARGS --tokenfile /work/token \ + --srcdir /qemu --src-tarball /work/qemu-sources.tgz if [ ! -z "$RESULTSTARBALL" ]; then echo "Copying results tarball to $RESULTSTARBALL..." cp "$SECRETDIR/cov-int.tar.xz" "$RESULTSTARBALL" --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905031; cv=none; d=zohomail.com; s=zohoarc; b=S1MQKBbutlT3h1AktsARmAJN5VtEAgr/D8wXJR83R/YElRAIbAmOgLUIxab5k6AxZ3STEsBN+UYIe93CSnE1lXVNAFdu6plJtFMZINAmyQxL515bk2XpWFYK/nA4mr0bOh1TbdmWUnjcn5KEfiB9dZa6NtJGQnCmlV31ITuy7vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905031; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ucbm30v1gOPnBVovAjuwcDEPB4Pjf4KkcMD5kjEUqv0=; b=M2CnDfwDnhSUMd8ReYoHSaFuuvYLmYNJ+G2z2waNGVKDjm/IZY1z6tPGkJFC3C5XORTjhAfZgAlTTMDuCDXUi966/Ik0Xym69cGeJ/RYO/sZxFx53Q8bbrKk6WvPLTPyFgQ9Ee3if6Zv+cUGDOZTdnAu2cv6cwqjfybUYDX0R+I= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905031631251.66981265307356; Thu, 11 Jun 2020 12:50:31 -0700 (PDT) Received: from localhost ([::1]:59606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTDZ-0005vm-LE for importer@patchew.org; Thu, 11 Jun 2020 15:50:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8I-0007E9-Ln for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:02 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36285 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000m3-Um for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-JnCS0YloN32gHghLt9XXqQ-1; Thu, 11 Jun 2020 15:44:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 897321800D41; Thu, 11 Jun 2020 19:44:54 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 317745EE0E; Thu, 11 Jun 2020 19:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904698; 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=ucbm30v1gOPnBVovAjuwcDEPB4Pjf4KkcMD5kjEUqv0=; b=CtHSvoLDoXV0P7nlA56Ye73fKtILGt7bJb+oyvfJ4CWlkR8o3iO21VuWWHq3SmfOnJU/T6 HJkdb3trFqQgLbJc5u5ZrNGQgbjDLBwFuFSmyCAZwMDvU6q1zrSDfqAZ8imYmTZfEJZvZj vWh77NwQFliQWyTnwzaC0S2yLlT1k7o= X-MC-Unique: JnCS0YloN32gHghLt9XXqQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 007/115] run-coverity-scan: download tools outside the container Date: Thu, 11 Jun 2020 15:43:01 -0400 Message-Id: <20200611194449.31468-8-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This lets us look at coverity_tool.md5 across executions of run-coverity-sc= an and skip the download. Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/coverity-scan.docker | 3 +- scripts/coverity-scan/run-coverity-scan | 42 +++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/scripts/coverity-scan/coverity-scan.docker b/scripts/coverity-= scan/coverity-scan.docker index 6f0460b66c..efcf63224d 100644 --- a/scripts/coverity-scan/coverity-scan.docker +++ b/scripts/coverity-scan/coverity-scan.docker @@ -127,5 +127,6 @@ RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt ENV PATH $PATH:/usr/libexec/python3-sphinx/ ENV COVERITY_TOOL_BASE=3D/coverity-tools +COPY coverity_tool.tgz coverity_tool.tgz +RUN mkdir -p /coverity-tools/coverity_tool && cd /coverity-tools/coverity_= tool && tar xf /coverity_tool.tgz COPY run-coverity-scan run-coverity-scan -RUN ./run-coverity-scan --update-tools-only --tokenfile /work/token diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index 6bb38b4f48..8bff952bf5 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -116,15 +116,17 @@ update_coverity_tools () { echo "Downloaded tarball didn't match md5sum!" exit 1 fi - # extract the new one, keeping it corralled in a 'coverity_tool' d= irectory - echo "Unpacking coverity build tools..." - mkdir -p coverity_tool - cd coverity_tool - tar xf ../coverity_tool.tgz - cd .. - mv coverity_tool.md5.new coverity_tool.md5 - fi =20 + if [ "$DOCKER" !=3D yes ]; then + # extract the new one, keeping it corralled in a 'coverity_too= l' directory + echo "Unpacking coverity build tools..." + mkdir -p coverity_tool + cd coverity_tool + tar xf ../coverity_tool.tgz + cd .. + mv coverity_tool.md5.new coverity_tool.md5 + fi + fi rm -f coverity_tool.md5.new } =20 @@ -296,6 +298,14 @@ if [ -z "$COVERITY_EMAIL" ]; then COVERITY_EMAIL=3D"$(git config user.email)" fi =20 +# Otherwise, continue with the full build and upload process. + +check_upload_permissions + +if [ "$UPDATE" !=3D no ]; then + update_coverity_tools +fi + # Run ourselves inside docker if that's what the user wants if [ "$DOCKER" =3D yes ]; then # Put the Coverity token into a temporary file that only @@ -315,13 +325,13 @@ if [ "$DOCKER" =3D yes ]; then if [ "$UPDATE" !=3D no ]; then # build docker container including the coverity-scan tools echo "Building docker container..." - # TODO: This re-downloads the tools every time, rather than - # caching and reusing the image produced with the downloaded tools. + # TODO: This re-unpacks the tools every time, rather than caching + # and reusing the image produced by the COPY of the .tgz file. # Not sure why. tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ -t coverity-scanner -f scripts/coverity-scan/coveri= ty-scan.docker \ - -v "$SECRETDIR:/work" \ - --extra-files scripts/coverity-scan/run-coverity-sc= an + --extra-files scripts/coverity-scan/run-coverity-sc= an \ + "$COVERITY_TOOL_BASE"/coverity_tool.t= gz fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" @@ -352,14 +362,6 @@ if [ "$DOCKER" =3D yes ]; then exit 0 fi =20 -# Otherwise, continue with the full build and upload process. - -check_upload_permissions - -if [ "$UPDATE" !=3D no ]; then - update_coverity_tools -fi - TOOLBIN=3D"$(cd "$COVERITY_TOOL_BASE" && echo $PWD/coverity_tool/cov-analy= sis-*/bin)" =20 if ! test -x "$TOOLBIN/cov-build"; then --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591904856; cv=none; d=zohomail.com; s=zohoarc; b=VvkN/rZJ0DYym9M51bk9kvaADg4r7IYbZmGten8aeeSfnRy5od6jWTzJSa07vv3qNI27c0dYmJcndjqys8xDJ948qIgnCtQfvtkH6DpnU3EgvCDBnqujOO7nIj5E1PHkwdy5Mkslsgyq5FhLdP3yg0HQKEI32G3JD6kzWShd4eE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591904856; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j4FdChKq6cAC1AvirjpOGLQBCc9XB8opK4v+ZgHbNbU=; b=DdbX8pUtDVTt2FFG22fXE43VBAjKVpSCkCbhyV9qUidPxZoLzpmtUz066lZJ+tNL5ORLJqQDdf663kAhKFxG99zBepsGQcpc7n536AcbS0vpmi6Yx4+BHR38itng35wIkFa6nMJV0COr+5xpnqoX+z0lLAQBk0f1UVbHLMZigxY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190485658364.38262806012995; Thu, 11 Jun 2020 12:47:36 -0700 (PDT) Received: from localhost ([::1]:51198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTAl-0001NS-6z for importer@patchew.org; Thu, 11 Jun 2020 15:47:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8H-0007CT-74 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51593 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8E-0000ls-Po for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-MrPeADYhNJOGZqcYGoyQeQ-1; Thu, 11 Jun 2020 15:44:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 147B0801503; Thu, 11 Jun 2020 19:44:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B06485EE0E; Thu, 11 Jun 2020 19:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904697; 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=j4FdChKq6cAC1AvirjpOGLQBCc9XB8opK4v+ZgHbNbU=; b=V8bLYnRh6dU05OgvyYV7TED4n48gfly0zqSWRcKNTABIPyGelLkygBuDIiK00RY9a0K80H 3bMdl+iqy5ZJzy/7U9EiRX45a+CY1xkIvJ5rhEpRZ90vHKE4koXqWdognf4D6dB4guw2lY GiabuO8b0EbZs/uT/m4FkZy/VL+UfUY= X-MC-Unique: MrPeADYhNJOGZqcYGoyQeQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 008/115] run-coverity-scan: support --update-tools-only --docker Date: Thu, 11 Jun 2020 15:43:02 -0400 Message-Id: <20200611194449.31468-9-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Just build the container when run-coverity-scan is invoked with --update-tools-only --docker. This requires moving the "docker build" logic into the update_coverity_tools function. The only snag is that --update-tools-only --docker requires access to the dockerfile. For now just report an error for --src-tarball, and "docker build" will fail if not in a source tree. Another possibility could be to host our container images on a public registry, and use "FROM qemu:fedora" to make the Dockerfile small enough that it can be included directly in the run-coverity-scan script. Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index 8bff952bf5..03a791dec9 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -95,6 +95,18 @@ check_upload_permissions() { } =20 =20 +build_docker_image() { + # build docker container including the coverity-scan tools + echo "Building docker container..." + # TODO: This re-unpacks the tools every time, rather than caching + # and reusing the image produced by the COPY of the .tgz file. + # Not sure why. + tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ + -t coverity-scanner -f scripts/coverity-scan/coverity-s= can.docker \ + --extra-files scripts/coverity-scan/run-coverity-scan \ + "$COVERITY_TOOL_BASE"/coverity_tool.tgz +} + update_coverity_tools () { # Check for whether we need to download the Coverity tools # (either because we don't have a copy, or because it's out of date) @@ -128,6 +140,11 @@ update_coverity_tools () { fi fi rm -f coverity_tool.md5.new + cd "$SRCDIR" + + if [ "$DOCKER" =3D yes ]; then + build_docker_image + fi } =20 =20 @@ -252,15 +269,16 @@ fi PROJNAME=3DQEMU TARBALL=3Dcov-int.tar.xz =20 -if [ "$UPDATE" =3D only ] && [ "$DOCKER" =3D yes ]; then - echo "Combining --docker and --update-only is not supported" - exit 1 -fi - if [ "$UPDATE" =3D only ]; then # Just do the tools update; we don't need to check whether # we are in a source tree or have upload rights for this, # so do it before some of the command line and source tree checks. + + if [ "$DOCKER" =3D yes ] && [ ! -z "$SRCTARBALL" ]; then + echo --update-tools-only --docker is incompatible with --src-tarba= ll. + exit 1 + fi + update_coverity_tools exit 0 fi @@ -322,17 +340,6 @@ if [ "$DOCKER" =3D yes ]; then echo "Created temporary directory $SECRETDIR" SECRET=3D"$SECRETDIR/token" echo "$COVERITY_TOKEN" > "$SECRET" - if [ "$UPDATE" !=3D no ]; then - # build docker container including the coverity-scan tools - echo "Building docker container..." - # TODO: This re-unpacks the tools every time, rather than caching - # and reusing the image produced by the COPY of the .tgz file. - # Not sure why. - tests/docker/docker.py --engine ${DOCKER_ENGINE} build \ - -t coverity-scanner -f scripts/coverity-scan/coveri= ty-scan.docker \ - --extra-files scripts/coverity-scan/run-coverity-sc= an \ - "$COVERITY_TOOL_BASE"/coverity_tool.t= gz - fi echo "Archiving sources to be analyzed..." ./scripts/archive-source.sh "$SECRETDIR/qemu-sources.tgz" ARGS=3D"--no-update-tools" --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905535; cv=none; d=zohomail.com; s=zohoarc; b=EXkzWXb++obdV2qOUtiolCzVy+gUUdSVL+jr9QRejrGu6zUw6PDlY4f84QiHfN/9WN8ZVqWXrhgCPkRJY9twrM4AwlAnNhwVKChnYnx7t/OlfRY+jhSc/sQ14BS2o0KMqyl2o2WNOE1Xg9VVqV0Fj/glBIHSDpISBpuBx24vxiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905535; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nGWM2hNLocwo2GTocEC9QFnmpSz++kZYwy0QI1FJpC4=; b=cQfFgnJzPJdpHb6upqMdY9ZxlB6PfbPn/9cn00lt3sEfZppW54b70a+wvyJIbUMn18ok01+tqhNZtvEVC4+r0fHlkCfLpa0vtT/oMG5w7amvPkvESRjlE07ghV0XIiUgl3hIEQHqLxhktVStrDI/DGi2Ao69+NE6FSkZqmYqiMk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905535515867.156602954722; Thu, 11 Jun 2020 12:58:55 -0700 (PDT) Received: from localhost ([::1]:60162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTLh-0002wp-US for importer@patchew.org; Thu, 11 Jun 2020 15:58:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8k-0007lW-5Q for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47928 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8h-0000yw-HG for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-Du7e0vxgMaOy_CHnh1q6mA-1; Thu, 11 Jun 2020 15:44:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94D1219057A0 for ; Thu, 11 Jun 2020 19:44:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3B75EE0E; Thu, 11 Jun 2020 19:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904726; 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=nGWM2hNLocwo2GTocEC9QFnmpSz++kZYwy0QI1FJpC4=; b=Ee0LGvUwLnkTaSprPmUsp+ou9fVpdEfGL3VaW2m30qwt4lGCmESQq7dCJW3uGvUfa0ZGJm Jj91DAXMEMpuCKaUayD16OUlrilvELHD0j97Hrvt1n9t33KIrkA9Ur08HXGujMYzADsv1s RWHCYBRQloiTkMDDGv7e1s5wkD7UFt8= X-MC-Unique: Du7e0vxgMaOy_CHnh1q6mA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 009/115] vl.c: run preconfig loop before creating default RAM backend Date: Thu, 11 Jun 2020 15:43:03 -0400 Message-Id: <20200611194449.31468-10-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Default RAM backend depends on numa_uses_legacy_mem(), which is infulenced by -numa options on CLI or set-numa-node QMP command at preconfig time. If QEMU is started with '-preconfig' without -numa, it will lead to creating default RAM backend even if later set-numa-node is used to assing RAM to NUMA nodes using 'memdev' NUMA option. That at best will waste RAM object created by default and with next patch adding a check to prevent usage of conflicting '-M memory-backend' and '-numa memdev' options, it will make QEMU error out if user tries to configure NUMA at preconfig time with memdev option, making set-numa-node unusable. To fix issue, move preconfig loop before default RAM backend is created, so that numa_uses_legacy_mem() would take into account effects of set-numa-node commands executed at preconfig time. Signed-off-by: Igor Mammedov Message-Id: <20200511141103.43768-2-imammedo@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 05d1a4cb6b..055472da66 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4334,12 +4334,13 @@ void qemu_init(int argc, char **argv, char **envp) =20 parse_numa_opts(current_machine); =20 + /* do monitor/qmp handling at preconfig state if requested */ + qemu_main_loop(); + if (machine_class->default_ram_id && current_machine->ram_size && numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { create_default_memdev(current_machine, mem_path); } - /* do monitor/qmp handling at preconfig state if requested */ - qemu_main_loop(); =20 audio_init_audiodevs(); =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591904858; cv=none; d=zohomail.com; s=zohoarc; b=TeB0HlEBrnX9VXT2yz73PUP8KgE16syeSLMuki166fRdQLo0IeE2lvhiM80U2UH+Z7QIOmbi79hu37PfHGQmo9ABkCdlkFgrzEK3bbxqOxPPksuBWEl1UvHmKoPzWTWwlSsCZ+a+r8qtBA6OmgrNgcnr0G6DDoAF1CRizAQvc3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591904858; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UT6Y/EMhcVfat9Z0INd94k9cWEH2ylW9qZ3/PBUOBs0=; b=GqNfEApHMdYQRAEzHIMbVHURTs9l9IzuwJyhYi5DLeL6LQCeV/iXBvZqc0JtkeRvBW/sYDGRpxs9rS/pa0jRptBjBLEwxGLbxPEF3jp3azBZ17NCLFjzwTnY5MStXRP8o05BpqwsIrJDEKgd+VyxktLzNP1f7EmL6fRrdK0gcQ0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190485896012.650750889666938; Thu, 11 Jun 2020 12:47:38 -0700 (PDT) Received: from localhost ([::1]:51534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTAn-0001Wp-Kp for importer@patchew.org; Thu, 11 Jun 2020 15:47:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8L-0007Gx-1F for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40749 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8J-0000nE-4b for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-TNSKf_RrPmeHai9cqNh2dA-1; Thu, 11 Jun 2020 15:45:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23C0D107ACCA for ; Thu, 11 Jun 2020 19:44:57 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A96F860CC0; Thu, 11 Jun 2020 19:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904702; 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=UT6Y/EMhcVfat9Z0INd94k9cWEH2ylW9qZ3/PBUOBs0=; b=RVqeGfy25Gr/GuvmVXkOkk3td0xu/lrFdAP5R0FOusWgaaLj60oFJFqnQiMm5rWn0ztjLF 5s895w89Nw+Cg4r/bP2UAq9KaHGcErfebz3Yq/IfbVH4SiK4/uA5iyNzwRkpaVBYlmYUCk 2ZyybqXE9ux0HMl7hphhaT+dKjoTD8s= X-MC-Unique: TNSKf_RrPmeHai9cqNh2dA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 010/115] numa: prevent usage of -M memory-backend and -numa memdev at the same time Date: Thu, 11 Jun 2020 15:43:04 -0400 Message-Id: <20200611194449.31468-11-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Options -M memory-backend and -numa memdev are mutually exclusive, and if used together, it might lead to a crash in the worst case. For example when the same backend is used with these options together: -m 4G \ -object memory-backend-ram,id=3Dmem0,size=3D4G \ -M pc,memory-backend=3Dmem0 \ -numa node,memdev=3Dmem0 QEMU will abort with: exec.c:2006: qemu_ram_set_idstr: Assertion `!new_block->idstr[0]' failed. and following backtrace: abort () qemu_ram_set_idstr () vmstate_register_ram () vmstate_register_ram_global () machine_consume_memdev () numa_init_memdev_container () numa_complete_configuration () machine_run_board_init () add a check to error out in case the user tries to use both options at the same time. Signed-off-by: Igor Mammedov Message-Id: <20200511141103.43768-3-imammedo@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/numa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/core/numa.c b/hw/core/numa.c index 316bc50d75..5f81900f88 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -757,6 +757,11 @@ void numa_complete_configuration(MachineState *ms) } =20 if (!numa_uses_legacy_mem() && mc->default_ram_id) { + if (ms->ram_memdev_id) { + error_report("'-machine memory-backend' and '-numa memdev'" + " properties are mutually exclusive"); + exit(1); + } ms->ram =3D g_new(MemoryRegion, 1); memory_region_init(ms->ram, OBJECT(ms), mc->default_ram_id, ram_size); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905378; cv=none; d=zohomail.com; s=zohoarc; b=R1C8JfXvy7x2AH51Y1icNPHsdH+cyPEHTFENXv4pyVg53ZvlqfldtBZpi28Km5ecI4WF5rMdDV2HSGN21GiU8vp9jtniqtFw05IPEFGg61bkoDNaxyMb/Koqj9Ta7nRhkXU3W17HSGBV+7EPPfmvuoMHUNtNHJz6UOrwIHE7lo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905378; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cBKfrTprAHuwZsgp6tzfJ36X7teGtKYtH1MnqsWCe/k=; b=TI2fsAUP9Uhv+DA+ZlfdqLk028WlljP9b99I/ZqcUumihSI4DgA33I4aUlUUNc5avu33PXDWUrUwhcXhnKwFicsC3d9lCedJL9t/rIA+B1n5J91BUaf+3H9mhPpfahej0H88rTG0D5r8MXfjDHgYVdCsHIShAUz9/6DSPHxC2KQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190537843446.975446675506305; Thu, 11 Jun 2020 12:56:18 -0700 (PDT) Received: from localhost ([::1]:51486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTJB-0006s4-48 for importer@patchew.org; Thu, 11 Jun 2020 15:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8K-0007Gd-Np for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:04 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39785 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8I-0000ms-JW for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-EEG2IenhN_egTrkR8HK4xg-1; Thu, 11 Jun 2020 15:44:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CCB4100A68C; Thu, 11 Jun 2020 19:44:58 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5411360CC0; Thu, 11 Jun 2020 19:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904701; 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=cBKfrTprAHuwZsgp6tzfJ36X7teGtKYtH1MnqsWCe/k=; b=eymHB0rv1xQktkDaioe3gSZjd7UKzsZyMQ6HWH2x53cWYsVTVK/nVHSyBXG9TMsxcOYnlz abgzxU5Dfkbmi8YlbDEGxUrWFmyHdvcRxRnn2NvKu1trCL4i+kslgriifAT6yDqqykT11+ a6i1wgnhHLTGW7MOiZQOphxefE4Y9uA= X-MC-Unique: EEG2IenhN_egTrkR8HK4xg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 011/115] icount: fix shift=auto for record/replay Date: Thu, 11 Jun 2020 15:43:05 -0400 Message-Id: <20200611194449.31468-12-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Dovgalyuk , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk This patch fixes shift=3Dauto when record/replay is enabled. Now user does not need to guess the best shift value. Signed-off-by: Pavel Dovgalyuk -- v2: moved icount_time_shift to vmstate subsection Message-Id: <158988500050.15192.692077802469400393.stgit@pasha-ThinkPad-X28= 0> Signed-off-by: Paolo Bonzini --- cpus.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 5670c96bcf..7ce0d569b3 100644 --- a/cpus.c +++ b/cpus.c @@ -379,7 +379,8 @@ static void icount_adjust(void) =20 seqlock_write_lock(&timers_state.vm_clock_seqlock, &timers_state.vm_clock_lock); - cur_time =3D cpu_get_clock_locked(); + cur_time =3D REPLAY_CLOCK_LOCKED(REPLAY_CLOCK_VIRTUAL_RT, + cpu_get_clock_locked()); cur_icount =3D cpu_get_icount_locked(); =20 delta =3D cur_icount - cur_time; @@ -647,6 +648,11 @@ static bool adjust_timers_state_needed(void *opaque) return s->icount_rt_timer !=3D NULL; } =20 +static bool shift_state_needed(void *opaque) +{ + return use_icount =3D=3D 2; +} + /* * Subsection for warp timer migration is optional, because may not be cre= ated */ @@ -674,6 +680,17 @@ static const VMStateDescription icount_vmstate_adjust_= timers =3D { } }; =20 +static const VMStateDescription icount_vmstate_shift =3D { + .name =3D "timer/icount/shift", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D shift_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_INT16(icount_time_shift, TimersState), + VMSTATE_END_OF_LIST() + } +}; + /* * This is a subsection for icount migration. */ @@ -690,6 +707,7 @@ static const VMStateDescription icount_vmstate_timers = =3D { .subsections =3D (const VMStateDescription*[]) { &icount_vmstate_warp_timer, &icount_vmstate_adjust_timers, + &icount_vmstate_shift, NULL } }; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905381; cv=none; d=zohomail.com; s=zohoarc; b=DSYv4oDZvk0mb4CofV0SPwA7Ebi+lbDOp5JuTcjYUrS07+oAtCxoUl4FJ/XoDH53dHIdWi0kdvqwvqi9TAhlNUnBN4B1DhbeIwlOT/UOACLwpVsU3zX7EHGVAHvI+uH45Qw1kJ4tDZp2ZB0F0Pq8Dp2bBLPlwKJ1nJFFWIMjQBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905381; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hijUk5uiY3tThGyqGp2dK/1kEFzv4beqcQ8rk+uJ0cM=; b=P3aUGU7qK9Ka4HmcFGbs4ea15HCxZf15eqQSEcYFxm5WT2LJfNAJ6BuX5CiQDhky223xWApH10tAN6mWpXxdOu599Utjr4HWt5+IvizRNLWzOt1eRQTMQTfcYRw8/wDRqpBXryhDvzZvN5P5Ckq6zhfatvF4hUNgFWJNDU3BSfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905381057836.6211931185974; Thu, 11 Jun 2020 12:56:21 -0700 (PDT) Received: from localhost ([::1]:51770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTJD-00073P-N6 for importer@patchew.org; Thu, 11 Jun 2020 15:56:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8f-0007eY-AJ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58067 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8Y-0000uw-Qi for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-izAqN0PTNhuXKmg1eUcbjw-1; Thu, 11 Jun 2020 15:45:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D7DE8018A6; Thu, 11 Jun 2020 19:45:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D72060CC0; Thu, 11 Jun 2020 19:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904717; 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=hijUk5uiY3tThGyqGp2dK/1kEFzv4beqcQ8rk+uJ0cM=; b=cC+q22TVGWXwz+okLnEaQnPX+873Zw3oMk818hjV0q12xIMt7/4MYLsnndnwSQwo3Ubyyf N5E1PA2sScjW1C1xJKX9ZVItEBHoNlFoJJRi91VbwCwCWzPkr3/wvOPRMztIxmpumopVjd wWTb8BTzydYfECyo/2STod8kJRNV4q4= X-MC-Unique: izAqN0PTNhuXKmg1eUcbjw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 012/115] qom/object: Fix object_child_foreach_recursive() return value Date: Thu, 11 Jun 2020 15:43:06 -0400 Message-Id: <20200611194449.31468-13-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Crosthwaite , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: C=C3=A9dric Le Goater When recursing, the return value of do_object_child_foreach() is not taken into account. Cc: Peter Crosthwaite Fixes: d714b8de7747 ("qom: Add recursive version of object_child_for_each") Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200404153340.164861-1-clg@kaod.org> Signed-off-by: Paolo Bonzini --- qom/object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index d0be42c8d6..484465f1c8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1051,7 +1051,10 @@ static int do_object_child_foreach(Object *obj, break; } if (recurse) { - do_object_child_foreach(child, fn, opaque, true); + ret =3D do_object_child_foreach(child, fn, opaque, true); + if (ret !=3D 0) { + break; + } } } } --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905859; cv=none; d=zohomail.com; s=zohoarc; b=HxXtgUr52KcOwZbcQbTIuT87MtMh6/HZhrhYQvkNagdVTJVq2/oKoKliHjtgY6FY748qKw8IkYWUFGrYsz4tjVF5FXU5lC0nWGGwoCvEEflFtBZaBhMW4p4m7Itghpggo8tSeSDZiFDsgHDBgariWL0uZv9Yx7+vRt7EEvS3i/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905859; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eNI90hF5jWb7xRl5hBHJFOvP+eCf2slz7DXLlGdAccw=; b=oLXNIh/0cktghuT+/gz0XYuIy9eMKdV3mzn6FyQj7dCbaBDSO7t4v172fnPNC0gpYQ84k20KaxI7hUXQ5OiM6LNbczfGgRoBNPMU8soCvknXFAMFg881VOqa86INkAGW6x/hQMiYSKv/JK9L5f3R5lEPcACQcFQdtMtf6VXFml0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905859366286.9069102039431; Thu, 11 Jun 2020 13:04:19 -0700 (PDT) Received: from localhost ([::1]:45346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTQv-0001AK-NX for importer@patchew.org; Thu, 11 Jun 2020 16:04:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8l-0007nV-5k for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:32 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:49208 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8h-0000yy-Eh for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-334-O6-2OJ0jMgOCytxMhSAXbA-1; Thu, 11 Jun 2020 15:45:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 022D3100A68F; Thu, 11 Jun 2020 19:45:03 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E1BC60CC0; Thu, 11 Jun 2020 19:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904726; 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=eNI90hF5jWb7xRl5hBHJFOvP+eCf2slz7DXLlGdAccw=; b=aW0vIDK+jkCsiLIxbJM3hlMBiUnIjBRMbXVq+vFgr6AVEU9zrBezfYfn2yikwvw5m8EI/l YKdKDwV2ddQ9ULXjeztBXJkxI+NHosULLKjVVY1uUYY9y3q2RlXUbIoI8eRHkMxY18rzLp 0zzWdKStzrMwwPilRtrJERPUC2cF2WM= X-MC-Unique: O6-2OJ0jMgOCytxMhSAXbA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 013/115] target/i386: Fix OUTL debug output Date: Thu, 11 Jun 2020 15:43:07 -0400 Message-Id: <20200611194449.31468-14-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Fix OUTL instructions incorrectly displayed as OUTW. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200517110147.26026-1-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- target/i386/misc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/misc_helper.c b/target/i386/misc_helper.c index 7d61221024..b6b1d41b14 100644 --- a/target/i386/misc_helper.c +++ b/target/i386/misc_helper.c @@ -70,7 +70,7 @@ target_ulong helper_inw(CPUX86State *env, uint32_t port) void helper_outl(CPUX86State *env, uint32_t port, uint32_t data) { #ifdef CONFIG_USER_ONLY - fprintf(stderr, "outw: port=3D0x%04x, data=3D%08x\n", port, data); + fprintf(stderr, "outl: port=3D0x%04x, data=3D%08x\n", port, data); #else address_space_stl(&address_space_io, port, data, cpu_get_mem_attrs(env), NULL); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906035; cv=none; d=zohomail.com; s=zohoarc; b=D36VGRt0r/QnvRZECUVtn97PsbPnW4y4JHbc4/SCYOHwOM5NhVd+5fut9HSaLKy1zJsOMhnGN5dtWWf3aCJyc7kGYZkm8qt5KNXOo9rt07EDIEMr/ayFM/BdeIcM9QiNj8zKfXSCyE26tJMk7M24pG3OVJPCZRrgOVGAXMIYAGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906035; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7oa8JasYJVEKYYlm2jMKtBXTwkbJOCM9mWA3N9ZVAqs=; b=HDCSjDzOvrI1jZZ7SV7BI3r85GrmaGxATww1TRDTRfjdGBL/69zcp96cGRa/p7cTLvo6pl0pZAku39FEa44i2DMOcNtrYFbNI0yCOw7XR0jwoqU+ehHHfB8dgZYkOC5gd2ZCKimhKTrCxOYJ11XMTwHWWoKFdEji8fZfh1M1OwE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906035721803.5971423095702; Thu, 11 Jun 2020 13:07:15 -0700 (PDT) Received: from localhost ([::1]:54668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTTm-0005Pb-Gm for importer@patchew.org; Thu, 11 Jun 2020 16:07:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT99-00086w-RO for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56359 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT91-00019i-Pt for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-ahBkQjBcPNSjTb0R9ucxRQ-1; Thu, 11 Jun 2020 15:45:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0433A0C00; Thu, 11 Jun 2020 19:45:03 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3322860CC0; Thu, 11 Jun 2020 19:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904746; 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=7oa8JasYJVEKYYlm2jMKtBXTwkbJOCM9mWA3N9ZVAqs=; b=XFZ85W0U3A2R37kJSqau6iTbIbtnCAA9YlzuKtyKVFLg0WgP3u7+kfOCV4gSOUowDF11SC bAVycRnqdMF+Gb35AiiZtUTjrndNpUKN1y2ia4ChRoCJfyiVDSO4wRy4RePeysaCDNCvQ4 DiuTDg/XmhdAmZcpDeTJ4Glhr3uqn8w= X-MC-Unique: ahBkQjBcPNSjTb0R9ucxRQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 014/115] qom/object: Move Object typedef to 'qemu/typedefs.h' Date: Thu, 11 Jun 2020 15:43:08 -0400 Message-Id: <20200611194449.31468-15-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 We use the Object type all over the place. Forward declare it in "qemu/typedefs.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200504115656.6045-2-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- hw/block/vhost-user-blk.c | 1 - hw/pci-host/pam.c | 1 - hw/scsi/vhost-user-scsi.c | 1 - include/hw/display/edid.h | 3 --- include/qemu/typedefs.h | 1 + include/qom/object.h | 2 -- include/qom/qom-qobject.h | 2 -- include/sysemu/sysemu.h | 1 - stubs/qmp_memory_device.c | 1 - 9 files changed, 1 insertion(+), 12 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9d8c0b3909..98941019a2 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -20,7 +20,6 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/cutils.h" -#include "qom/object.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost.h" diff --git a/hw/pci-host/pam.c b/hw/pci-host/pam.c index 45c4333cd3..a496205783 100644 --- a/hw/pci-host/pam.c +++ b/hw/pci-host/pam.c @@ -28,7 +28,6 @@ */ =20 #include "qemu/osdep.h" -#include "qom/object.h" #include "hw/pci-host/pam.h" =20 void init_pam(DeviceState *dev, MemoryRegion *ram_memory, diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index cbb5d97599..f2e524438a 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -18,7 +18,6 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "qom/object.h" #include "hw/fw-path-provider.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h index 23371ee82c..5b1de57f24 100644 --- a/include/hw/display/edid.h +++ b/include/hw/display/edid.h @@ -1,9 +1,6 @@ #ifndef EDID_H #define EDID_H =20 -#include "qom/object.h" -#include "hw/qdev-properties.h" - typedef struct qemu_edid_info { const char *vendor; /* http://www.uefi.org/pnp_id_list */ const char *name; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index ecf3cde26c..de68d51d52 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -76,6 +76,7 @@ typedef struct NetFilterState NetFilterState; typedef struct NICInfo NICInfo; typedef struct NodeInfo NodeInfo; typedef struct NumaNodeMem NumaNodeMem; +typedef struct Object Object; typedef struct ObjectClass ObjectClass; typedef struct PCIBridge PCIBridge; typedef struct PCIBus PCIBus; diff --git a/include/qom/object.h b/include/qom/object.h index fd453dc8d6..c7c97ead60 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -20,8 +20,6 @@ struct TypeImpl; typedef struct TypeImpl *Type; =20 -typedef struct Object Object; - typedef struct TypeInfo TypeInfo; =20 typedef struct InterfaceClass InterfaceClass; diff --git a/include/qom/qom-qobject.h b/include/qom/qom-qobject.h index 77cd717e3f..82136e6e80 100644 --- a/include/qom/qom-qobject.h +++ b/include/qom/qom-qobject.h @@ -13,8 +13,6 @@ #ifndef QEMU_QOM_QOBJECT_H #define QEMU_QOM_QOBJECT_H =20 -#include "qom/object.h" - /* * object_property_get_qobject: * @obj: the object diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 3efccdba7e..4b6a5c459c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -5,7 +5,6 @@ #include "qemu/timer.h" #include "qemu/notify.h" #include "qemu/uuid.h" -#include "qom/object.h" =20 /* vl.c */ =20 diff --git a/stubs/qmp_memory_device.c b/stubs/qmp_memory_device.c index 85ff8f2d7e..e75cac62dc 100644 --- a/stubs/qmp_memory_device.c +++ b/stubs/qmp_memory_device.c @@ -1,5 +1,4 @@ #include "qemu/osdep.h" -#include "qom/object.h" #include "hw/mem/memory-device.h" =20 MemoryDeviceInfoList *qmp_memory_device_list(void) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905239; cv=none; d=zohomail.com; s=zohoarc; b=cQk4In1udirQ1/mKJiwXb03Oq328IBsYkNpb31TCcaWvc3q4ujTE0K6XDli3aty4NBaRdgr8o7LKzm8BTHrrBsKsrULPxZgvbxFGoROXwJ1ZK4b4WepXfmWwxT8fGLd3PthQHqAy8htLrY+KqbBfhHgbLtL5M81sR3t7OXLnvl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k7arBjwywDdVge+nq40Wb/WPqdlhhkJBZ1JLGzgHBd0=; b=CXdTqGtmjDSMMcFgfsrp+ddSBX6nmbtN/E8/3kUOFjy0YvvKoEqJaI0k3yzBZS84TJ6+SxLEJiko95O88Oc1HoaSi2e4HWqhb3CSSccKKIQJaonexp3UBAeHFYSrtUTj8wxVPLWZbsjYbByZIkuRzOQgwdHMy/JOJ7nN/2zCKWY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905239167156.46097720071953; Thu, 11 Jun 2020 12:53:59 -0700 (PDT) Received: from localhost ([::1]:43292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTGu-0003Gj-Q9 for importer@patchew.org; Thu, 11 Jun 2020 15:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8V-0007VU-Bs for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54826 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8T-0000qz-Er for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-vYN2wNuUNW2ININfFuQ1Zw-1; Thu, 11 Jun 2020 15:45:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49244107ACCA; Thu, 11 Jun 2020 19:45:04 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C5F60CC0; Thu, 11 Jun 2020 19:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904712; 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=k7arBjwywDdVge+nq40Wb/WPqdlhhkJBZ1JLGzgHBd0=; b=IQ9et49jR2K16v1eCW9XHEVVEdgLNBTcnkwTS3JRbhlDcDM8gtjYZhbawfuiZ4XCLLyQ7Y Yr6yM0AfjFkZtjHTiRZgZA4jHEVEkMCfXtWJu5kePKVg/nkap2Wdb7OvD2eRC5oESHq30a k79ZcrcSg4Bp9zTsHlHWU36F2brRCvg= X-MC-Unique: vYN2wNuUNW2ININfFuQ1Zw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 015/115] io/task: Move 'qom/object.h' header to source Date: Thu, 11 Jun 2020 15:43:09 -0400 Message-Id: <20200611194449.31468-16-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 We need "qom/object.h" to call object_ref()/object_unref(), and to test the TYPE_DUMMY. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200504115656.6045-3-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- include/io/task.h | 2 -- io/task.c | 1 + tests/test-io-task.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/io/task.h b/include/io/task.h index 1abbfb8b65..6818dfedd0 100644 --- a/include/io/task.h +++ b/include/io/task.h @@ -21,8 +21,6 @@ #ifndef QIO_TASK_H #define QIO_TASK_H =20 -#include "qom/object.h" - typedef struct QIOTask QIOTask; =20 typedef void (*QIOTaskFunc)(QIOTask *task, diff --git a/io/task.c b/io/task.c index 1ae7b86488..53c0bed686 100644 --- a/io/task.c +++ b/io/task.c @@ -22,6 +22,7 @@ #include "io/task.h" #include "qapi/error.h" #include "qemu/thread.h" +#include "qom/object.h" #include "trace.h" =20 struct QIOTaskThreadData { diff --git a/tests/test-io-task.c b/tests/test-io-task.c index aa8b653bfa..c8a3813d49 100644 --- a/tests/test-io-task.c +++ b/tests/test-io-task.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" =20 +#include "qom/object.h" #include "io/task.h" #include "qapi/error.h" #include "qemu/module.h" --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905082; cv=none; d=zohomail.com; s=zohoarc; b=J1DnMDo9YDkDo7RadEVsQKSi2wKe4t2F/vHvqFer0nw7E3tl/L7kNL1GcZbwDdpQ3u36TrkNF5vOEFueEtdL3bjPqcTtzcSYjoTh0RUnC9Gd62IEPQNAF06mbdFZwGjeVd75SoEb9mff62917VlfeHfluieqRuL7gJKlCZiWKSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905082; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e2SGOCNL6XL6xuFV5X4LrCpFwE7kT/D02iFNt5rRIl4=; b=EccUDVYPA+S630NfAZ8Jw5u26voVP/hqdp8Rn6GaxbmQVs5hdWp9gIHAf3subh2Bmyk9Ff6yhIs4qeX/QK4DsHY4HJDkO+GQA7aC0Hw8fwCJptUctiwPIlyuAI0HNvmjzXYk9jim4I5QhudQ+0o/XW6zEovYvC54BO+IsZ7Wl1U= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905082266812.8103229767562; Thu, 11 Jun 2020 12:51:22 -0700 (PDT) Received: from localhost ([::1]:34716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTEO-0007P9-TG for importer@patchew.org; Thu, 11 Jun 2020 15:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8U-0007UB-67 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:14 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:26077 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8R-0000pO-H4 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-90-ImVkDhkkPf6EDYP1B91sPw-1; Thu, 11 Jun 2020 15:45:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09F0C461 for ; Thu, 11 Jun 2020 19:45:08 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A27060CC0; Thu, 11 Jun 2020 19:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904710; 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=e2SGOCNL6XL6xuFV5X4LrCpFwE7kT/D02iFNt5rRIl4=; b=eJrbvtA49kKFQdj5gsQe7s4X8skeU6d5Qj/fMk2s1ddr+R1/SmcI+krAuPmzi9iLU098D9 OEgDF/TxlnJxpr00Wi+b67ymI9EWltwpHD/h0uXJgr9FNM05a7ciyNUWMfD5VWp7iGj0HL HlEQOpi1N7byj9oaYqPXRRdprLuhaH8= X-MC-Unique: ImVkDhkkPf6EDYP1B91sPw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 016/115] Makefile: Let the 'help' target list the helper targets Date: Thu, 11 Jun 2020 15:43:10 -0400 Message-Id: <20200611194449.31468-17-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 List the name of the helper targets when calling 'make help', along with the tool targets: $ make help [...] Helper targets: fsdev/virtfs-proxy-helper - Build virtfs-proxy-helper scsi/qemu-pr-helper - Build qemu-pr-helper qemu-bridge-helper - Build qemu-bridge-helper vhost-user-gpu - Build vhost-user-gpu virtiofsd - Build virtiofsd Tools targets: qemu-ga - Build qemu-ga tool qemu-keymap - Build qemu-keymap tool elf2dmp - Build elf2dmp tool ivshmem-client - Build ivshmem-client tool ivshmem-server - Build ivshmem-server tool qemu-nbd - Build qemu-nbd tool qemu-storage-daemon - Build qemu-storage-daemon tool qemu-img - Build qemu-img tool qemu-io - Build qemu-io tool qemu-edid - Build qemu-edid tool Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- Makefile | 9 +++++++-- configure | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d1af126ea1..ed0ed93b2d 100644 --- a/Makefile +++ b/Makefile @@ -336,9 +336,9 @@ $(call set-vpath, $(SRC_PATH)) LIBS+=3D-lz $(LIBS_TOOLS) =20 vhost-user-json-y =3D -HELPERS-y =3D +HELPERS-y =3D $(HELPERS) =20 -HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) =3D qemu-bridge-hel= per$(EXESUF) +HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) +=3D qemu-bridge-he= lper$(EXESUF) =20 ifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),yyyy) HELPERS-y +=3D vhost-user-gpu$(EXESUF) @@ -1258,6 +1258,11 @@ endif $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \ ))) \ echo '') + @$(if $(HELPERS-y), \ + echo 'Helper targets:'; \ + $(foreach t, $(HELPERS-y), \ + $(call print-help-run,$(t),Build $(shell basename $(t)));) \ + echo '') @$(if $(TOOLS), \ echo 'Tools targets:'; \ $(foreach t, $(TOOLS), \ diff --git a/configure b/configure index 597e909b53..53a6dd0297 100755 --- a/configure +++ b/configure @@ -6394,7 +6394,7 @@ if test "$softmmu" =3D yes ; then if test "$linux" =3D yes; then if test "$virtfs" !=3D no && test "$cap_ng" =3D yes && test "$attr" = =3D yes ; then virtfs=3Dyes - tools=3D"$tools fsdev/virtfs-proxy-helper\$(EXESUF)" + helpers=3D"$helpers fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" =3D yes; then error_exit "VirtFS requires libcap-ng devel and libattr devel" @@ -6409,7 +6409,7 @@ if test "$softmmu" =3D yes ; then fi mpath=3Dno fi - tools=3D"$tools scsi/qemu-pr-helper\$(EXESUF)" + helpers=3D"$helpers scsi/qemu-pr-helper\$(EXESUF)" else if test "$virtfs" =3D yes; then error_exit "VirtFS is supported only on Linux" @@ -7651,6 +7651,7 @@ else QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES" fi =20 +echo "HELPERS=3D$helpers" >> $config_host_mak echo "TOOLS=3D$tools" >> $config_host_mak echo "ROMS=3D$roms" >> $config_host_mak echo "MAKE=3D$make" >> $config_host_mak --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907076; cv=none; d=zohomail.com; s=zohoarc; b=QXIrqs6/ehJdC6ktFxGrFiW2zwExZyUHPO4GzDM4QwQtf92fXG6dWuMYx4g/02Zx7RgH0UUVT9/ljT3S3lXsuMEPPr655UeEuAM75gC02Ca2Xu2wD7HF9DFpjIISHSJAqWvPElMa135SNyMnoMZ0lHBGLwwun7B+d37Z/tSwI+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907076; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FnVW+q5k7WUlLd05tyYL72pgIZMJJCUmWa0BR/hltaI=; b=QSEWpPlyXYMtWbSpZFflQa3qup5hxY7E3+neuYgQ0q9LHAF+VNpXTCwQwgO0IKhTR7ZHOe8chZ2pCBJ+P4Y+sCYCeUOxcIGr7sETMlDBCNAIPnl7UFXNA0JHp8QIk1xaNKlYkEZGtyfQgMpg1tbq82GzH9RPg8NiLegpmrbe8rg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907076855956.8665118296154; Thu, 11 Jun 2020 13:24:36 -0700 (PDT) Received: from localhost ([::1]:36818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTkZ-0003Qg-Fx for importer@patchew.org; Thu, 11 Jun 2020 16:24:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT91-00085A-S1 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52360 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8w-00016F-Og for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-sq-fFeQ_P-2D24g8a4vIsg-1; Thu, 11 Jun 2020 15:45:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7719A0C00; Thu, 11 Jun 2020 19:45:08 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A4E660CD3; Thu, 11 Jun 2020 19:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904741; 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=FnVW+q5k7WUlLd05tyYL72pgIZMJJCUmWa0BR/hltaI=; b=PwLAhIXD+gdW7+mBeYDtcaN3Eesv1fGpZoas6ReH+xpQikpXW8ikCqt44CuuNlQv9FlaiE sFr5ps0Po8tijvIf5f3b8hjB9oQ+ML/Qeg/HFpcddFgmaQ/zvSarTItDm/KpMtl8r99OB3 bQE9hxwEVcblo3CXhNvybez3zvChgXY= X-MC-Unique: sq-fFeQ_P-2D24g8a4vIsg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 017/115] hyperv: expose API to determine if synic is enabled Date: Thu, 11 Jun 2020 15:43:11 -0400 Message-Id: <20200611194449.31468-18-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Doron Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-2-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- hw/hyperv/hyperv.c | 8 ++++++++ include/hw/hyperv/hyperv.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 4b11f7a76b..a3933c34c6 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -38,6 +38,13 @@ typedef struct SynICState { #define TYPE_SYNIC "hyperv-synic" #define SYNIC(obj) OBJECT_CHECK(SynICState, (obj), TYPE_SYNIC) =20 +static bool synic_enabled; + +bool hyperv_is_synic_enabled(void) +{ + return synic_enabled; +} + static SynICState *get_synic(CPUState *cs) { return SYNIC(object_resolve_path_component(OBJECT(cs), "synic")); @@ -134,6 +141,7 @@ void hyperv_synic_add(CPUState *cs) object_property_add_child(OBJECT(cs), "synic", obj); object_unref(obj); object_property_set_bool(obj, true, "realized", &error_abort); + synic_enabled =3D true; } =20 void hyperv_synic_reset(CPUState *cs) diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index 597381cb01..a63ee0003c 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -79,5 +79,6 @@ void hyperv_synic_add(CPUState *cs); void hyperv_synic_reset(CPUState *cs); void hyperv_synic_update(CPUState *cs, bool enable, hwaddr msg_page_addr, hwaddr event_page_addr); +bool hyperv_is_synic_enabled(void); =20 #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905539; cv=none; d=zohomail.com; s=zohoarc; b=Y6DuO5TP27j8Exgvk0HxPrIctdgYftB6glzc0vzWNJrq0lURhHdBDmhVUxT9xMk6Rb99/T2D1dTeEHXscgg1O47ZsWEKZfmZXMb1/80XoO2fmsdx8W6VPcnfvX5yKXYuObmNkTTXROEoGLMoeJmcGmIViPHXx2Kv0Zi4KfKF15E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vtxO6BHV6g2zCUKIB0YNiqh82uRelwV67KidagQ0NP8=; b=XL03B74ckFgZxVTmTWSIXJEWn53b3ZUF0hgEXE4sWQoFVRm8SQt4p323G6Y8SiNR6dWwrvlewkcQTnbg8oiotDD+x2uzWU5PR2V3l3xu1FPUb4CmBJcrw5+zgM7HlrKtJ5+q2kkTJB7r62X3MuIx9FrTk4XzboNXBd85kGjypqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905539514627.5627769144414; Thu, 11 Jun 2020 12:58:59 -0700 (PDT) Received: from localhost ([::1]:60438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTLl-00033m-UN for importer@patchew.org; Thu, 11 Jun 2020 15:58:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8a-0007aC-IN for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38724 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8W-0000tw-MX for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-IZnGZ1zRMMyN76i9MgRwdQ-1; Thu, 11 Jun 2020 15:45:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8938F1800D41; Thu, 11 Jun 2020 19:45:09 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D85C860CD3; Thu, 11 Jun 2020 19:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904715; 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=vtxO6BHV6g2zCUKIB0YNiqh82uRelwV67KidagQ0NP8=; b=Cm/bG0YXSLUBy6oRtdJFjqaP9p/rRHbwCGyaW5IyMNsZWvaMZAQmXlaM3YZ6zRvZb27EVo PQNbOVdP4UKQvVYSF1Cw56q/OQ2Jz/l/uFSePaz9TbtqhTQY/25PfzBTEHKLu/EWiirMxt FeZZbn7uWrpbrTLaLx8teq4uYcUtMvs= X-MC-Unique: IZnGZ1zRMMyN76i9MgRwdQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 018/115] vmbus: add vmbus protocol definitions Date: Thu, 11 Jun 2020 15:43:12 -0400 Message-Id: <20200611194449.31468-19-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Maciej S . Szmigiero" , Jon Doron , Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jon Doron Add a header with data structures and constants used in Hyper-V VMBus hypervisor <-> guest interactions. Based on the respective stuff from Linux kernel. Signed-off-by: Roman Kagan Signed-off-by: Maciej S. Szmigiero Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-3-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- include/hw/hyperv/vmbus-proto.h | 222 ++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 include/hw/hyperv/vmbus-proto.h diff --git a/include/hw/hyperv/vmbus-proto.h b/include/hw/hyperv/vmbus-prot= o.h new file mode 100644 index 0000000000..4628d3b323 --- /dev/null +++ b/include/hw/hyperv/vmbus-proto.h @@ -0,0 +1,222 @@ +/* + * QEMU Hyper-V VMBus support + * + * Copyright (c) 2017-2018 Virtuozzo International GmbH. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_HYPERV_VMBUS_PROTO_H +#define HW_HYPERV_VMBUS_PROTO_H + +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) +#define VMBUS_VERSION_WIN10 ((4 << 16) | (0)) +#define VMBUS_VERSION_INVAL -1 +#define VMBUS_VERSION_CURRENT VMBUS_VERSION_WIN10 + +#define VMBUS_MESSAGE_CONNECTION_ID 1 +#define VMBUS_EVENT_CONNECTION_ID 2 +#define VMBUS_MONITOR_CONNECTION_ID 3 +#define VMBUS_SINT 2 + +#define VMBUS_MSG_INVALID 0 +#define VMBUS_MSG_OFFERCHANNEL 1 +#define VMBUS_MSG_RESCIND_CHANNELOFFER 2 +#define VMBUS_MSG_REQUESTOFFERS 3 +#define VMBUS_MSG_ALLOFFERS_DELIVERED 4 +#define VMBUS_MSG_OPENCHANNEL 5 +#define VMBUS_MSG_OPENCHANNEL_RESULT 6 +#define VMBUS_MSG_CLOSECHANNEL 7 +#define VMBUS_MSG_GPADL_HEADER 8 +#define VMBUS_MSG_GPADL_BODY 9 +#define VMBUS_MSG_GPADL_CREATED 10 +#define VMBUS_MSG_GPADL_TEARDOWN 11 +#define VMBUS_MSG_GPADL_TORNDOWN 12 +#define VMBUS_MSG_RELID_RELEASED 13 +#define VMBUS_MSG_INITIATE_CONTACT 14 +#define VMBUS_MSG_VERSION_RESPONSE 15 +#define VMBUS_MSG_UNLOAD 16 +#define VMBUS_MSG_UNLOAD_RESPONSE 17 +#define VMBUS_MSG_COUNT 18 + +#define VMBUS_MESSAGE_SIZE_ALIGN sizeof(uint64_t) + +#define VMBUS_PACKET_INVALID 0x0 +#define VMBUS_PACKET_SYNCH 0x1 +#define VMBUS_PACKET_ADD_XFER_PAGESET 0x2 +#define VMBUS_PACKET_RM_XFER_PAGESET 0x3 +#define VMBUS_PACKET_ESTABLISH_GPADL 0x4 +#define VMBUS_PACKET_TEARDOWN_GPADL 0x5 +#define VMBUS_PACKET_DATA_INBAND 0x6 +#define VMBUS_PACKET_DATA_USING_XFER_PAGES 0x7 +#define VMBUS_PACKET_DATA_USING_GPADL 0x8 +#define VMBUS_PACKET_DATA_USING_GPA_DIRECT 0x9 +#define VMBUS_PACKET_CANCEL_REQUEST 0xa +#define VMBUS_PACKET_COMP 0xb +#define VMBUS_PACKET_DATA_USING_ADDITIONAL_PKT 0xc +#define VMBUS_PACKET_ADDITIONAL_DATA 0xd + +#define VMBUS_CHANNEL_USER_DATA_SIZE 120 + +#define VMBUS_OFFER_MONITOR_ALLOCATED 0x1 +#define VMBUS_OFFER_INTERRUPT_DEDICATED 0x1 + +#define VMBUS_RING_BUFFER_FEAT_PENDING_SZ (1ul << 0) + +#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 0x1 +#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 0x2 +#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 0x4 +#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10 +#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 +#define VMBUS_CHANNEL_PARENT_OFFER 0x200 +#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 +#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER 0x2000 + +#define VMBUS_PACKET_FLAG_REQUEST_COMPLETION 1 + +typedef struct vmbus_message_header { + uint32_t message_type; + uint32_t _padding; +} vmbus_message_header; + +typedef struct vmbus_message_initiate_contact { + vmbus_message_header header; + uint32_t version_requested; + uint32_t target_vcpu; + uint64_t interrupt_page; + uint64_t monitor_page1; + uint64_t monitor_page2; +} vmbus_message_initiate_contact; + +typedef struct vmbus_message_version_response { + vmbus_message_header header; + uint8_t version_supported; + uint8_t status; +} vmbus_message_version_response; + +typedef struct vmbus_message_offer_channel { + vmbus_message_header header; + uint8_t type_uuid[16]; + uint8_t instance_uuid[16]; + uint64_t _reserved1; + uint64_t _reserved2; + uint16_t channel_flags; + uint16_t mmio_size_mb; + uint8_t user_data[VMBUS_CHANNEL_USER_DATA_SIZE]; + uint16_t sub_channel_index; + uint16_t _reserved3; + uint32_t child_relid; + uint8_t monitor_id; + uint8_t monitor_flags; + uint16_t interrupt_flags; + uint32_t connection_id; +} vmbus_message_offer_channel; + +typedef struct vmbus_message_rescind_channel_offer { + vmbus_message_header header; + uint32_t child_relid; +} vmbus_message_rescind_channel_offer; + +typedef struct vmbus_gpa_range { + uint32_t byte_count; + uint32_t byte_offset; + uint64_t pfn_array[]; +} vmbus_gpa_range; + +typedef struct vmbus_message_gpadl_header { + vmbus_message_header header; + uint32_t child_relid; + uint32_t gpadl_id; + uint16_t range_buflen; + uint16_t rangecount; + vmbus_gpa_range range[]; +} QEMU_PACKED vmbus_message_gpadl_header; + +typedef struct vmbus_message_gpadl_body { + vmbus_message_header header; + uint32_t message_number; + uint32_t gpadl_id; + uint64_t pfn_array[]; +} vmbus_message_gpadl_body; + +typedef struct vmbus_message_gpadl_created { + vmbus_message_header header; + uint32_t child_relid; + uint32_t gpadl_id; + uint32_t status; +} vmbus_message_gpadl_created; + +typedef struct vmbus_message_gpadl_teardown { + vmbus_message_header header; + uint32_t child_relid; + uint32_t gpadl_id; +} vmbus_message_gpadl_teardown; + +typedef struct vmbus_message_gpadl_torndown { + vmbus_message_header header; + uint32_t gpadl_id; +} vmbus_message_gpadl_torndown; + +typedef struct vmbus_message_open_channel { + vmbus_message_header header; + uint32_t child_relid; + uint32_t open_id; + uint32_t ring_buffer_gpadl_id; + uint32_t target_vp; + uint32_t ring_buffer_offset; + uint8_t user_data[VMBUS_CHANNEL_USER_DATA_SIZE]; +} vmbus_message_open_channel; + +typedef struct vmbus_message_open_result { + vmbus_message_header header; + uint32_t child_relid; + uint32_t open_id; + uint32_t status; +} vmbus_message_open_result; + +typedef struct vmbus_message_close_channel { + vmbus_message_header header; + uint32_t child_relid; +} vmbus_message_close_channel; + +typedef struct vmbus_ring_buffer { + uint32_t write_index; + uint32_t read_index; + uint32_t interrupt_mask; + uint32_t pending_send_sz; + uint32_t _reserved1[12]; + uint32_t feature_bits; +} vmbus_ring_buffer; + +typedef struct vmbus_packet_hdr { + uint16_t type; + uint16_t offset_qwords; + uint16_t len_qwords; + uint16_t flags; + uint64_t transaction_id; +} vmbus_packet_hdr; + +typedef struct vmbus_pkt_gpa_direct { + uint32_t _reserved; + uint32_t rangecount; + vmbus_gpa_range range[]; +} vmbus_pkt_gpa_direct; + +typedef struct vmbus_xferpg_range { + uint32_t byte_count; + uint32_t byte_offset; +} vmbus_xferpg_range; + +typedef struct vmbus_pkt_xferpg { + uint16_t buffer_id; + uint8_t sender_owns_set; + uint8_t _reserved; + uint32_t rangecount; + vmbus_xferpg_range range[]; +} vmbus_pkt_xferpg; + +#endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907645; cv=none; d=zohomail.com; s=zohoarc; b=YDvBtHxqTCrl3P5OCcD7nYy7Ff9WT4zN7g4zaGMnVaXSAtkPuPqkt5Ho3qZRymjufZxCGQpiXw/IgazgrmWywMYxtw+mEuJR1T6Lqo9LGcuXy+AQLLtRryN8brF7a473Hj+C8dn6rCt24EGS0bvqbmw40/YBKlVSpEqiPjpfN6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907645; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/Epp0mXYaW0KOaFH+PJ6MG5YOfO3D0VqYp2AAf+AYiU=; b=V6tLB5olpVZ/liK7BHP8cpt8CWcHys4hb55sf9eIOVIi40lLY/tY6ltSZjdPnbvBbyAyvrd+yEZisYhvefMDMeEKfQDqFH76vZVXNFvCwUKnoNQEeJQ0+YwAuQ/Yj0AaUbBE33zgmEdM1muUjdxO+5tZ7MQvVVlXtbllPAIY+gI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907645326913.0174841021479; Thu, 11 Jun 2020 13:34:05 -0700 (PDT) Received: from localhost ([::1]:40626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTtj-0001kW-No for importer@patchew.org; Thu, 11 Jun 2020 16:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9h-0000Tc-2e for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:29 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:43252 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9c-0001I6-3z for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-n_W2bW9aOJaYmCELd2QX1Q-1; Thu, 11 Jun 2020 15:45:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B798B107ACF2; Thu, 11 Jun 2020 19:45:10 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB9A360CC0; Thu, 11 Jun 2020 19:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904783; 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=/Epp0mXYaW0KOaFH+PJ6MG5YOfO3D0VqYp2AAf+AYiU=; b=U7SzADgP2/YIDAoyuKprBZIdRSUitzARLKNDuE/zTF7eVlnRtSk4ewJGfvviGXzyMuDNfU EEUN5mc0w/HCo2/twvD1shG7px22lEliw6OSAziFmn1qt1zaftys9gH0GRrdPTo3APp8Di ZwJldO5rD6J7/fhS2Q4Lwl27o0eRZ8s= X-MC-Unique: n_W2bW9aOJaYmCELd2QX1Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 019/115] vmbus: vmbus implementation Date: Thu, 11 Jun 2020 15:43:13 -0400 Message-Id: <20200611194449.31468-20-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Maciej S . Szmigiero" , Jon Doron , Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jon Doron Add the VMBus infrastructure -- bus, devices, root bridge, vmbus state machine, vmbus channel interactions, etc. VMBus is a collection of technologies. At its lowest layer, it's a message passing and signaling mechanism, allowing efficient passing of messages to = and from guest VMs. A layer higher, it's a mechanism for defining channels of communication, where each channel is tagged with a type (which implies a protocol) and a instance ID. A layer higher than that, it's a bus driver, serving as the basis of device enumeration within a VM, where a channel can optionally be exposed as a paravirtual device. When a server-side (paravir= tual back-end) component wishes to offer a channel to a guest VM, it does so by specifying a channel type, a mode, and an instance ID. VMBus then exposes = this in the guest. More information about VMBus can be found in the file vmbuskernelmodeclientlibapi.h in Microsoft's WDK. TODO: - split into smaller palatable pieces - more comments - check and handle corner cases Kudos to Evgeny Yakovlev (formerly eyakovlev@virtuozzo.com) and Andrey Smetatin (formerly asmetanin@virtuozzo.com) for research and prototyping. Signed-off-by: Roman Kagan Signed-off-by: Maciej S. Szmigiero Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-4-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- Makefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2672 ++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 32 + include/hw/hyperv/vmbus.h | 227 +++ 7 files changed, 2956 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus.h diff --git a/Makefile.objs b/Makefile.objs index 99774cfd25..c09d95dfe3 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -150,6 +150,7 @@ trace-events-subdirs +=3D hw/block/dataplane trace-events-subdirs +=3D hw/char trace-events-subdirs +=3D hw/dma trace-events-subdirs +=3D hw/hppa +trace-events-subdirs +=3D hw/hyperv trace-events-subdirs +=3D hw/i2c trace-events-subdirs +=3D hw/i386 trace-events-subdirs +=3D hw/i386/xen diff --git a/hw/hyperv/Kconfig b/hw/hyperv/Kconfig index a1fa8ff9be..3fbfe41c9e 100644 --- a/hw/hyperv/Kconfig +++ b/hw/hyperv/Kconfig @@ -6,3 +6,8 @@ config HYPERV_TESTDEV bool default y if TEST_DEVICES depends on HYPERV + +config VMBUS + bool + default y + depends on HYPERV diff --git a/hw/hyperv/Makefile.objs b/hw/hyperv/Makefile.objs index edaca2f763..5b614e040c 100644 --- a/hw/hyperv/Makefile.objs +++ b/hw/hyperv/Makefile.objs @@ -1,2 +1,3 @@ obj-y +=3D hyperv.o obj-$(CONFIG_HYPERV_TESTDEV) +=3D hyperv_testdev.o +obj-$(CONFIG_VMBUS) +=3D vmbus.o diff --git a/hw/hyperv/trace-events b/hw/hyperv/trace-events new file mode 100644 index 0000000000..ba5bd62d61 --- /dev/null +++ b/hw/hyperv/trace-events @@ -0,0 +1,18 @@ +# vmbus +vmbus_recv_message(uint32_t type, uint32_t size) "type %d size %d" +vmbus_signal_event(void) "" +vmbus_channel_notify_guest(uint32_t chan_id) "channel #%d" +vmbus_post_msg(uint32_t type, uint32_t size) "type %d size %d" +vmbus_msg_cb(int status) "message status %d" +vmbus_process_incoming_message(uint32_t message_type) "type %d" +vmbus_initiate_contact(uint16_t major, uint16_t minor, uint32_t vcpu, uint= 64_t monitor_page1, uint64_t monitor_page2, uint64_t interrupt_page) "versi= on %d.%d target vp %d mon pages 0x%"PRIx64",0x%"PRIx64" int page 0x%"PRIx64 +vmbus_send_offer(uint32_t chan_id, void *dev) "channel #%d dev %p" +vmbus_terminate_offers(void) "" +vmbus_gpadl_header(uint32_t gpadl_id, uint16_t num_gfns) "gpadl #%d gfns %= d" +vmbus_gpadl_body(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_created(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_teardown(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_torndown(uint32_t gpadl_id) "gpadl #%d" +vmbus_open_channel(uint32_t chan_id, uint32_t gpadl_id, uint32_t target_vp= ) "channel #%d gpadl #%d target vp %d" +vmbus_channel_open(uint32_t chan_id, uint32_t status) "channel #%d status = %d" +vmbus_close_channel(uint32_t chan_id) "channel #%d" diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c new file mode 100644 index 0000000000..802bbc8c96 --- /dev/null +++ b/hw/hyperv/vmbus.c @@ -0,0 +1,2672 @@ +/* + * QEMU Hyper-V VMBus + * + * Copyright (c) 2017-2018 Virtuozzo International GmbH. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/hyperv/hyperv.h" +#include "hw/hyperv/vmbus.h" +#include "hw/hyperv/vmbus-bridge.h" +#include "hw/sysbus.h" +#include "cpu.h" +#include "trace.h" + +#define TYPE_VMBUS "vmbus" +#define VMBUS(obj) OBJECT_CHECK(VMBus, (obj), TYPE_VMBUS) + +enum { + VMGPADL_INIT, + VMGPADL_ALIVE, + VMGPADL_TEARINGDOWN, + VMGPADL_TORNDOWN, +}; + +struct VMBusGpadl { + /* GPADL id */ + uint32_t id; + /* associated channel id (rudimentary?) */ + uint32_t child_relid; + + /* number of pages in the GPADL as declared in GPADL_HEADER message */ + uint32_t num_gfns; + /* + * Due to limited message size, GPADL may not fit fully in a single + * GPADL_HEADER message, and is further popluated using GPADL_BODY + * messages. @seen_gfns is the number of pages seen so far; once it + * reaches @num_gfns, the GPADL is ready to use. + */ + uint32_t seen_gfns; + /* array of GFNs (of size @num_gfns once allocated) */ + uint64_t *gfns; + + uint8_t state; + + QTAILQ_ENTRY(VMBusGpadl) link; + VMBus *vmbus; + unsigned refcount; +}; + +/* + * Wrap sequential read from / write to GPADL. + */ +typedef struct GpadlIter { + VMBusGpadl *gpadl; + AddressSpace *as; + DMADirection dir; + /* offset into GPADL where the next i/o will be performed */ + uint32_t off; + /* + * Cached mapping of the currently accessed page, up to page boundary. + * Updated lazily on i/o. + * Note: MemoryRegionCache can not be used here because pages in the G= PADL + * are non-contiguous and may belong to different memory regions. + */ + void *map; + /* offset after last i/o (i.e. not affected by seek) */ + uint32_t last_off; + /* + * Indicator that the iterator is active and may have a cached mapping. + * Allows to enforce bracketing of all i/o (which may create cached + * mappings) and thus exclude mapping leaks. + */ + bool active; +} GpadlIter; + +/* + * Ring buffer. There are two of them, sitting in the same GPADL, for each + * channel. + * Each ring buffer consists of a set of pages, with the first page contai= ning + * the ring buffer header, and the remaining pages being for data packets. + */ +typedef struct VMBusRingBufCommon { + AddressSpace *as; + /* GPA of the ring buffer header */ + dma_addr_t rb_addr; + /* start and length of the ring buffer data area within GPADL */ + uint32_t base; + uint32_t len; + + GpadlIter iter; +} VMBusRingBufCommon; + +typedef struct VMBusSendRingBuf { + VMBusRingBufCommon common; + /* current write index, to be committed at the end of send */ + uint32_t wr_idx; + /* write index at the start of send */ + uint32_t last_wr_idx; + /* space to be requested from the guest */ + uint32_t wanted; + /* space reserved for planned sends */ + uint32_t reserved; + /* last seen read index */ + uint32_t last_seen_rd_idx; +} VMBusSendRingBuf; + +typedef struct VMBusRecvRingBuf { + VMBusRingBufCommon common; + /* current read index, to be committed at the end of receive */ + uint32_t rd_idx; + /* read index at the start of receive */ + uint32_t last_rd_idx; + /* last seen write index */ + uint32_t last_seen_wr_idx; +} VMBusRecvRingBuf; + + +enum { + VMOFFER_INIT, + VMOFFER_SENDING, + VMOFFER_SENT, +}; + +enum { + VMCHAN_INIT, + VMCHAN_OPENING, + VMCHAN_OPEN, +}; + +struct VMBusChannel { + VMBusDevice *dev; + + /* channel id */ + uint32_t id; + /* + * subchannel index within the device; subchannel #0 is "primary" and + * always exists + */ + uint16_t subchan_idx; + uint32_t open_id; + /* VP_INDEX of the vCPU to notify with (synthetic) interrupts */ + uint32_t target_vp; + /* GPADL id to use for the ring buffers */ + uint32_t ringbuf_gpadl; + /* start (in pages) of the send ring buffer within @ringbuf_gpadl */ + uint32_t ringbuf_send_offset; + + uint8_t offer_state; + uint8_t state; + bool is_open; + + /* main device worker; copied from the device class */ + VMBusChannelNotifyCb notify_cb; + /* + * guest->host notifications, either sent directly or dispatched via + * interrupt page (older VMBus) + */ + EventNotifier notifier; + + VMBus *vmbus; + /* + * SINT route to signal with host->guest notifications; may be shared = with + * the main VMBus SINT route + */ + HvSintRoute *notify_route; + VMBusGpadl *gpadl; + + VMBusSendRingBuf send_ringbuf; + VMBusRecvRingBuf recv_ringbuf; + + QTAILQ_ENTRY(VMBusChannel) link; +}; + +/* + * Hyper-V spec mandates that every message port has 16 buffers, which mea= ns + * that the guest can post up to this many messages without blocking. + * Therefore a queue for incoming messages has to be provided. + * For outgoing (i.e. host->guest) messages there's no queue; the VMBus ju= st + * doesn't transition to a new state until the message is known to have be= en + * successfully delivered to the respective SynIC message slot. + */ +#define HV_MSG_QUEUE_LEN 16 + +/* Hyper-V devices never use channel #0. Must be something special. */ +#define VMBUS_FIRST_CHANID 1 +/* Each channel occupies one bit within a single event page sint slot. */ +#define VMBUS_CHANID_COUNT (HV_EVENT_FLAGS_COUNT - VMBUS_FIRST_CHANID) +/* Leave a few connection numbers for other purposes. */ +#define VMBUS_CHAN_CONNECTION_OFFSET 16 + +/* + * Since the success or failure of sending a message is reported + * asynchronously, the VMBus state machine has effectively two entry point= s: + * vmbus_run and vmbus_msg_cb (the latter is called when the host->guest + * message delivery status becomes known). Both are run as oneshot BHs on= the + * main aio context, ensuring serialization. + */ +enum { + VMBUS_LISTEN, + VMBUS_HANDSHAKE, + VMBUS_OFFER, + VMBUS_CREATE_GPADL, + VMBUS_TEARDOWN_GPADL, + VMBUS_OPEN_CHANNEL, + VMBUS_UNLOAD, + VMBUS_STATE_MAX +}; + +struct VMBus { + BusState parent; + + uint8_t state; + /* protection against recursive aio_poll (see vmbus_run) */ + bool in_progress; + /* whether there's a message being delivered to the guest */ + bool msg_in_progress; + uint32_t version; + /* VP_INDEX of the vCPU to send messages and interrupts to */ + uint32_t target_vp; + HvSintRoute *sint_route; + /* + * interrupt page for older protocol versions; newer ones use SynIC ev= ent + * flags directly + */ + hwaddr int_page_gpa; + + DECLARE_BITMAP(chanid_bitmap, VMBUS_CHANID_COUNT); + + /* incoming message queue */ + struct hyperv_post_message_input rx_queue[HV_MSG_QUEUE_LEN]; + uint8_t rx_queue_head; + uint8_t rx_queue_size; + QemuMutex rx_queue_lock; + + QTAILQ_HEAD(, VMBusGpadl) gpadl_list; + QTAILQ_HEAD(, VMBusChannel) channel_list; + + /* + * guest->host notifications for older VMBus, to be dispatched via + * interrupt page + */ + EventNotifier notifier; +}; + +static bool gpadl_full(VMBusGpadl *gpadl) +{ + return gpadl->seen_gfns =3D=3D gpadl->num_gfns; +} + +static VMBusGpadl *create_gpadl(VMBus *vmbus, uint32_t id, + uint32_t child_relid, uint32_t num_gfns) +{ + VMBusGpadl *gpadl =3D g_new0(VMBusGpadl, 1); + + gpadl->id =3D id; + gpadl->child_relid =3D child_relid; + gpadl->num_gfns =3D num_gfns; + gpadl->gfns =3D g_new(uint64_t, num_gfns); + QTAILQ_INSERT_HEAD(&vmbus->gpadl_list, gpadl, link); + gpadl->vmbus =3D vmbus; + gpadl->refcount =3D 1; + return gpadl; +} + +static void free_gpadl(VMBusGpadl *gpadl) +{ + QTAILQ_REMOVE(&gpadl->vmbus->gpadl_list, gpadl, link); + g_free(gpadl->gfns); + g_free(gpadl); +} + +static VMBusGpadl *find_gpadl(VMBus *vmbus, uint32_t gpadl_id) +{ + VMBusGpadl *gpadl; + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + if (gpadl->id =3D=3D gpadl_id) { + return gpadl; + } + } + return NULL; +} + +VMBusGpadl *vmbus_get_gpadl(VMBusChannel *chan, uint32_t gpadl_id) +{ + VMBusGpadl *gpadl =3D find_gpadl(chan->vmbus, gpadl_id); + if (!gpadl || !gpadl_full(gpadl)) { + return NULL; + } + gpadl->refcount++; + return gpadl; +} + +void vmbus_put_gpadl(VMBusGpadl *gpadl) +{ + if (!gpadl) { + return; + } + if (--gpadl->refcount) { + return; + } + free_gpadl(gpadl); +} + +uint32_t vmbus_gpadl_len(VMBusGpadl *gpadl) +{ + return gpadl->num_gfns * TARGET_PAGE_SIZE; +} + +static void gpadl_iter_init(GpadlIter *iter, VMBusGpadl *gpadl, + AddressSpace *as, DMADirection dir) +{ + iter->gpadl =3D gpadl; + iter->as =3D as; + iter->dir =3D dir; + iter->active =3D false; +} + +static inline void gpadl_iter_cache_unmap(GpadlIter *iter) +{ + uint32_t map_start_in_page =3D (uintptr_t)iter->map & ~TARGET_PAGE_MAS= K; + uint32_t io_end_in_page =3D ((iter->last_off - 1) & ~TARGET_PAGE_MASK)= + 1; + + /* mapping is only done to do non-zero amount of i/o */ + assert(iter->last_off > 0); + assert(map_start_in_page < io_end_in_page); + + dma_memory_unmap(iter->as, iter->map, TARGET_PAGE_SIZE - map_start_in_= page, + iter->dir, io_end_in_page - map_start_in_page); +} + +/* + * Copy exactly @len bytes between the GPADL pointed to by @iter and @buf. + * The direction of the copy is determined by @iter->dir. + * The caller must ensure the operation overflows neither @buf nor the GPA= DL + * (there's an assert for the latter). + * Reuse the currently mapped page in the GPADL if possible. + */ +static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf, uint32_t len) +{ + ssize_t ret =3D len; + + assert(iter->active); + + while (len) { + uint32_t off_in_page =3D iter->off & ~TARGET_PAGE_MASK; + uint32_t pgleft =3D TARGET_PAGE_SIZE - off_in_page; + uint32_t cplen =3D MIN(pgleft, len); + void *p; + + /* try to reuse the cached mapping */ + if (iter->map) { + uint32_t map_start_in_page =3D + (uintptr_t)iter->map & ~TARGET_PAGE_MASK; + uint32_t off_base =3D iter->off & ~TARGET_PAGE_MASK; + uint32_t mapped_base =3D (iter->last_off - 1) & ~TARGET_PAGE_M= ASK; + if (off_base !=3D mapped_base || off_in_page < map_start_in_pa= ge) { + gpadl_iter_cache_unmap(iter); + iter->map =3D NULL; + } + } + + if (!iter->map) { + dma_addr_t maddr; + dma_addr_t mlen =3D pgleft; + uint32_t idx =3D iter->off >> TARGET_PAGE_BITS; + assert(idx < iter->gpadl->num_gfns); + + maddr =3D (iter->gpadl->gfns[idx] << TARGET_PAGE_BITS) | off_i= n_page; + + iter->map =3D dma_memory_map(iter->as, maddr, &mlen, iter->dir= ); + if (mlen !=3D pgleft) { + dma_memory_unmap(iter->as, iter->map, mlen, iter->dir, 0); + iter->map =3D NULL; + return -EFAULT; + } + } + + p =3D (void *)(((uintptr_t)iter->map & TARGET_PAGE_MASK) | off_in_= page); + if (iter->dir =3D=3D DMA_DIRECTION_FROM_DEVICE) { + memcpy(p, buf, cplen); + } else { + memcpy(buf, p, cplen); + } + + buf +=3D cplen; + len -=3D cplen; + iter->off +=3D cplen; + iter->last_off =3D iter->off; + } + + return ret; +} + +/* + * Position the iterator @iter at new offset @new_off. + * If this results in the cached mapping being unusable with the new offse= t, + * unmap it. + */ +static inline void gpadl_iter_seek(GpadlIter *iter, uint32_t new_off) +{ + assert(iter->active); + iter->off =3D new_off; +} + +/* + * Start a series of i/o on the GPADL. + * After this i/o and seek operations on @iter become legal. + */ +static inline void gpadl_iter_start_io(GpadlIter *iter) +{ + assert(!iter->active); + /* mapping is cached lazily on i/o */ + iter->map =3D NULL; + iter->active =3D true; +} + +/* + * End the eariler started series of i/o on the GPADL and release the cach= ed + * mapping if any. + */ +static inline void gpadl_iter_end_io(GpadlIter *iter) +{ + assert(iter->active); + + if (iter->map) { + gpadl_iter_cache_unmap(iter); + } + + iter->active =3D false; +} + +static void vmbus_resched(VMBus *vmbus); +static void vmbus_msg_cb(void *data, int status); + +ssize_t vmbus_iov_to_gpadl(VMBusChannel *chan, VMBusGpadl *gpadl, uint32_t= off, + const struct iovec *iov, size_t iov_cnt) +{ + GpadlIter iter; + size_t i; + ssize_t ret =3D 0; + + gpadl_iter_init(&iter, gpadl, chan->dev->dma_as, + DMA_DIRECTION_FROM_DEVICE); + gpadl_iter_start_io(&iter); + gpadl_iter_seek(&iter, off); + for (i =3D 0; i < iov_cnt; i++) { + ret =3D gpadl_iter_io(&iter, iov[i].iov_base, iov[i].iov_len); + if (ret < 0) { + goto out; + } + } +out: + gpadl_iter_end_io(&iter); + return ret; +} + +int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *iov, + unsigned iov_cnt, size_t len, size_t off) +{ + int ret_cnt =3D 0, ret; + unsigned i; + QEMUSGList *sgl =3D &req->sgl; + ScatterGatherEntry *sg =3D sgl->sg; + + for (i =3D 0; i < sgl->nsg; i++) { + if (sg[i].len > off) { + break; + } + off -=3D sg[i].len; + } + for (; len && i < sgl->nsg; i++) { + dma_addr_t mlen =3D MIN(sg[i].len - off, len); + dma_addr_t addr =3D sg[i].base + off; + len -=3D mlen; + off =3D 0; + + for (; mlen; ret_cnt++) { + dma_addr_t l =3D mlen; + dma_addr_t a =3D addr; + + if (ret_cnt =3D=3D iov_cnt) { + ret =3D -ENOBUFS; + goto err; + } + + iov[ret_cnt].iov_base =3D dma_memory_map(sgl->as, a, &l, dir); + if (!l) { + ret =3D -EFAULT; + goto err; + } + iov[ret_cnt].iov_len =3D l; + addr +=3D l; + mlen -=3D l; + } + } + + return ret_cnt; +err: + vmbus_unmap_sgl(req, dir, iov, ret_cnt, 0); + return ret; +} + +void vmbus_unmap_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *io= v, + unsigned iov_cnt, size_t accessed) +{ + QEMUSGList *sgl =3D &req->sgl; + unsigned i; + + for (i =3D 0; i < iov_cnt; i++) { + size_t acsd =3D MIN(accessed, iov[i].iov_len); + dma_memory_unmap(sgl->as, iov[i].iov_base, iov[i].iov_len, dir, ac= sd); + accessed -=3D acsd; + } +} + +static const VMStateDescription vmstate_gpadl =3D { + .name =3D "vmbus/gpadl", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(id, VMBusGpadl), + VMSTATE_UINT32(child_relid, VMBusGpadl), + VMSTATE_UINT32(num_gfns, VMBusGpadl), + VMSTATE_UINT32(seen_gfns, VMBusGpadl), + VMSTATE_VARRAY_UINT32_ALLOC(gfns, VMBusGpadl, num_gfns, 0, + vmstate_info_uint64, uint64_t), + VMSTATE_UINT8(state, VMBusGpadl), + VMSTATE_END_OF_LIST() + } +}; + +/* + * Wrap the index into a ring buffer of @len bytes. + * @idx is assumed not to exceed twice the size of the ringbuffer, so only + * single wraparound is considered. + */ +static inline uint32_t rb_idx_wrap(uint32_t idx, uint32_t len) +{ + if (idx >=3D len) { + idx -=3D len; + } + return idx; +} + +/* + * Circular difference between two indices into a ring buffer of @len byte= s. + * @allow_catchup - whether @idx1 may catch up @idx2; e.g. read index may = catch + * up write index but not vice versa. + */ +static inline uint32_t rb_idx_delta(uint32_t idx1, uint32_t idx2, uint32_t= len, + bool allow_catchup) +{ + return rb_idx_wrap(idx2 + len - idx1 - !allow_catchup, len); +} + +static vmbus_ring_buffer *ringbuf_map_hdr(VMBusRingBufCommon *ringbuf) +{ + vmbus_ring_buffer *rb; + dma_addr_t mlen =3D sizeof(*rb); + + rb =3D dma_memory_map(ringbuf->as, ringbuf->rb_addr, &mlen, + DMA_DIRECTION_FROM_DEVICE); + if (mlen !=3D sizeof(*rb)) { + dma_memory_unmap(ringbuf->as, rb, mlen, + DMA_DIRECTION_FROM_DEVICE, 0); + return NULL; + } + return rb; +} + +static void ringbuf_unmap_hdr(VMBusRingBufCommon *ringbuf, + vmbus_ring_buffer *rb, bool dirty) +{ + assert(rb); + + dma_memory_unmap(ringbuf->as, rb, sizeof(*rb), DMA_DIRECTION_FROM_DEVI= CE, + dirty ? sizeof(*rb) : 0); +} + +static void ringbuf_init_common(VMBusRingBufCommon *ringbuf, VMBusGpadl *g= padl, + AddressSpace *as, DMADirection dir, + uint32_t begin, uint32_t end) +{ + ringbuf->as =3D as; + ringbuf->rb_addr =3D gpadl->gfns[begin] << TARGET_PAGE_BITS; + ringbuf->base =3D (begin + 1) << TARGET_PAGE_BITS; + ringbuf->len =3D (end - begin - 1) << TARGET_PAGE_BITS; + gpadl_iter_init(&ringbuf->iter, gpadl, as, dir); +} + +static int ringbufs_init(VMBusChannel *chan) +{ + vmbus_ring_buffer *rb; + VMBusSendRingBuf *send_ringbuf =3D &chan->send_ringbuf; + VMBusRecvRingBuf *recv_ringbuf =3D &chan->recv_ringbuf; + + if (chan->ringbuf_send_offset <=3D 1 || + chan->gpadl->num_gfns <=3D chan->ringbuf_send_offset + 1) { + return -EINVAL; + } + + ringbuf_init_common(&recv_ringbuf->common, chan->gpadl, chan->dev->dma= _as, + DMA_DIRECTION_TO_DEVICE, 0, chan->ringbuf_send_off= set); + ringbuf_init_common(&send_ringbuf->common, chan->gpadl, chan->dev->dma= _as, + DMA_DIRECTION_FROM_DEVICE, chan->ringbuf_send_offs= et, + chan->gpadl->num_gfns); + send_ringbuf->wanted =3D 0; + send_ringbuf->reserved =3D 0; + + rb =3D ringbuf_map_hdr(&recv_ringbuf->common); + if (!rb) { + return -EFAULT; + } + recv_ringbuf->rd_idx =3D recv_ringbuf->last_rd_idx =3D rb->read_index; + ringbuf_unmap_hdr(&recv_ringbuf->common, rb, false); + + rb =3D ringbuf_map_hdr(&send_ringbuf->common); + if (!rb) { + return -EFAULT; + } + send_ringbuf->wr_idx =3D send_ringbuf->last_wr_idx =3D rb->write_index; + send_ringbuf->last_seen_rd_idx =3D rb->read_index; + rb->feature_bits |=3D VMBUS_RING_BUFFER_FEAT_PENDING_SZ; + ringbuf_unmap_hdr(&send_ringbuf->common, rb, true); + + if (recv_ringbuf->rd_idx >=3D recv_ringbuf->common.len || + send_ringbuf->wr_idx >=3D send_ringbuf->common.len) { + return -EOVERFLOW; + } + + return 0; +} + +/* + * Perform io between the GPADL-backed ringbuffer @ringbuf and @buf, wrapp= ing + * around if needed. + * @len is assumed not to exceed the size of the ringbuffer, so only single + * wraparound is considered. + */ +static ssize_t ringbuf_io(VMBusRingBufCommon *ringbuf, void *buf, uint32_t= len) +{ + ssize_t ret1 =3D 0, ret2 =3D 0; + uint32_t remain =3D ringbuf->len + ringbuf->base - ringbuf->iter.off; + + if (len >=3D remain) { + ret1 =3D gpadl_iter_io(&ringbuf->iter, buf, remain); + if (ret1 < 0) { + return ret1; + } + gpadl_iter_seek(&ringbuf->iter, ringbuf->base); + buf +=3D remain; + len -=3D remain; + } + ret2 =3D gpadl_iter_io(&ringbuf->iter, buf, len); + if (ret2 < 0) { + return ret2; + } + return ret1 + ret2; +} + +/* + * Position the circular iterator within @ringbuf to offset @new_off, wrap= ping + * around if needed. + * @new_off is assumed not to exceed twice the size of the ringbuffer, so = only + * single wraparound is considered. + */ +static inline void ringbuf_seek(VMBusRingBufCommon *ringbuf, uint32_t new_= off) +{ + gpadl_iter_seek(&ringbuf->iter, + ringbuf->base + rb_idx_wrap(new_off, ringbuf->len)); +} + +static inline uint32_t ringbuf_tell(VMBusRingBufCommon *ringbuf) +{ + return ringbuf->iter.off - ringbuf->base; +} + +static inline void ringbuf_start_io(VMBusRingBufCommon *ringbuf) +{ + gpadl_iter_start_io(&ringbuf->iter); +} + +static inline void ringbuf_end_io(VMBusRingBufCommon *ringbuf) +{ + gpadl_iter_end_io(&ringbuf->iter); +} + +VMBusDevice *vmbus_channel_device(VMBusChannel *chan) +{ + return chan->dev; +} + +VMBusChannel *vmbus_device_channel(VMBusDevice *dev, uint32_t chan_idx) +{ + if (chan_idx >=3D dev->num_channels) { + return NULL; + } + return &dev->channels[chan_idx]; +} + +uint32_t vmbus_channel_idx(VMBusChannel *chan) +{ + return chan - chan->dev->channels; +} + +void vmbus_channel_notify_host(VMBusChannel *chan) +{ + event_notifier_set(&chan->notifier); +} + +bool vmbus_channel_is_open(VMBusChannel *chan) +{ + return chan->is_open; +} + +/* + * Notify the guest side about the data to work on in the channel ring buf= fer. + * The notification is done by signaling a dedicated per-channel SynIC eve= nt + * flag (more recent guests) or setting a bit in the interrupt page and fi= ring + * the VMBus SINT (older guests). + */ +static int vmbus_channel_notify_guest(VMBusChannel *chan) +{ + int res =3D 0; + unsigned long *int_map, mask; + unsigned idx; + hwaddr addr =3D chan->vmbus->int_page_gpa; + hwaddr len =3D TARGET_PAGE_SIZE / 2, dirty =3D 0; + + trace_vmbus_channel_notify_guest(chan->id); + + if (!addr) { + return hyperv_set_event_flag(chan->notify_route, chan->id); + } + + int_map =3D cpu_physical_memory_map(addr, &len, 1); + if (len !=3D TARGET_PAGE_SIZE / 2) { + res =3D -ENXIO; + goto unmap; + } + + idx =3D BIT_WORD(chan->id); + mask =3D BIT_MASK(chan->id); + if ((atomic_fetch_or(&int_map[idx], mask) & mask) !=3D mask) { + res =3D hyperv_sint_route_set_sint(chan->notify_route); + dirty =3D len; + } + +unmap: + cpu_physical_memory_unmap(int_map, len, 1, dirty); + return res; +} + +#define VMBUS_PKT_TRAILER sizeof(uint64_t) + +static uint32_t vmbus_pkt_hdr_set_offsets(vmbus_packet_hdr *hdr, + uint32_t desclen, uint32_t msgle= n) +{ + hdr->offset_qwords =3D sizeof(*hdr) / sizeof(uint64_t) + + DIV_ROUND_UP(desclen, sizeof(uint64_t)); + hdr->len_qwords =3D hdr->offset_qwords + + DIV_ROUND_UP(msglen, sizeof(uint64_t)); + return hdr->len_qwords * sizeof(uint64_t) + VMBUS_PKT_TRAILER; +} + +/* + * Simplified ring buffer operation with paired barriers annotations in the + * producer and consumer loops: + * + * producer * consumer + * ~~~~~~~~ * ~~~~~~~~ + * write pending_send_sz * read write_index + * smp_mb [A] * smp_mb [C] + * read read_index * read packet + * smp_mb [B] * read/write out-of-band data + * read/write out-of-band data * smp_mb [B] + * write packet * write read_index + * smp_mb [C] * smp_mb [A] + * write write_index * read pending_send_sz + * smp_wmb [D] * smp_rmb [D] + * write pending_send_sz * read write_index + * ... * ... + */ + +static inline uint32_t ringbuf_send_avail(VMBusSendRingBuf *ringbuf) +{ + /* don't trust guest data */ + if (ringbuf->last_seen_rd_idx >=3D ringbuf->common.len) { + return 0; + } + return rb_idx_delta(ringbuf->wr_idx, ringbuf->last_seen_rd_idx, + ringbuf->common.len, false); +} + +static ssize_t ringbuf_send_update_idx(VMBusChannel *chan) +{ + VMBusSendRingBuf *ringbuf =3D &chan->send_ringbuf; + vmbus_ring_buffer *rb; + uint32_t written; + + written =3D rb_idx_delta(ringbuf->last_wr_idx, ringbuf->wr_idx, + ringbuf->common.len, true); + if (!written) { + return 0; + } + + rb =3D ringbuf_map_hdr(&ringbuf->common); + if (!rb) { + return -EFAULT; + } + + ringbuf->reserved -=3D written; + + /* prevent reorder with the data operation and packet write */ + smp_mb(); /* barrier pair [C] */ + rb->write_index =3D ringbuf->wr_idx; + + /* + * If the producer earlier indicated that it wants to be notified when= the + * consumer frees certain amount of space in the ring buffer, that amo= unt + * is reduced by the size of the completed write. + */ + if (ringbuf->wanted) { + /* otherwise reservation would fail */ + assert(ringbuf->wanted < written); + ringbuf->wanted -=3D written; + /* prevent reorder with write_index write */ + smp_wmb(); /* barrier pair [D] */ + rb->pending_send_sz =3D ringbuf->wanted; + } + + /* prevent reorder with write_index or pending_send_sz write */ + smp_mb(); /* barrier pair [A] */ + ringbuf->last_seen_rd_idx =3D rb->read_index; + + /* + * The consumer may have missed the reduction of pending_send_sz and s= kip + * notification, so re-check the blocking condition, and, if it's no l= onger + * true, ensure processing another iteration by simulating consumer's + * notification. + */ + if (ringbuf_send_avail(ringbuf) >=3D ringbuf->wanted) { + vmbus_channel_notify_host(chan); + } + + /* skip notification by consumer's request */ + if (rb->interrupt_mask) { + goto out; + } + + /* + * The consumer hasn't caught up with the producer's previous state so= it's + * not blocked. + * (last_seen_rd_idx comes from the guest but it's safe to use w/o + * validation here as it only affects notification.) + */ + if (rb_idx_delta(ringbuf->last_seen_rd_idx, ringbuf->wr_idx, + ringbuf->common.len, true) > written) { + goto out; + } + + vmbus_channel_notify_guest(chan); +out: + ringbuf_unmap_hdr(&ringbuf->common, rb, true); + ringbuf->last_wr_idx =3D ringbuf->wr_idx; + return written; +} + +int vmbus_channel_reserve(VMBusChannel *chan, + uint32_t desclen, uint32_t msglen) +{ + VMBusSendRingBuf *ringbuf =3D &chan->send_ringbuf; + vmbus_ring_buffer *rb =3D NULL; + vmbus_packet_hdr hdr; + uint32_t needed =3D ringbuf->reserved + + vmbus_pkt_hdr_set_offsets(&hdr, desclen, msglen); + + /* avoid touching the guest memory if possible */ + if (likely(needed <=3D ringbuf_send_avail(ringbuf))) { + goto success; + } + + rb =3D ringbuf_map_hdr(&ringbuf->common); + if (!rb) { + return -EFAULT; + } + + /* fetch read index from guest memory and try again */ + ringbuf->last_seen_rd_idx =3D rb->read_index; + + if (likely(needed <=3D ringbuf_send_avail(ringbuf))) { + goto success; + } + + rb->pending_send_sz =3D needed; + + /* + * The consumer may have made progress and freed up some space before + * seeing updated pending_send_sz, so re-read read_index (preventing + * reorder with the pending_send_sz write) and try again. + */ + smp_mb(); /* barrier pair [A] */ + ringbuf->last_seen_rd_idx =3D rb->read_index; + + if (needed > ringbuf_send_avail(ringbuf)) { + goto out; + } + +success: + ringbuf->reserved =3D needed; + needed =3D 0; + + /* clear pending_send_sz if it was set */ + if (ringbuf->wanted) { + if (!rb) { + rb =3D ringbuf_map_hdr(&ringbuf->common); + if (!rb) { + /* failure to clear pending_send_sz is non-fatal */ + goto out; + } + } + + rb->pending_send_sz =3D 0; + } + + /* prevent reorder of the following data operation with read_index rea= d */ + smp_mb(); /* barrier pair [B] */ + +out: + if (rb) { + ringbuf_unmap_hdr(&ringbuf->common, rb, ringbuf->wanted =3D=3D nee= ded); + } + ringbuf->wanted =3D needed; + return needed ? -ENOSPC : 0; +} + +ssize_t vmbus_channel_send(VMBusChannel *chan, uint16_t pkt_type, + void *desc, uint32_t desclen, + void *msg, uint32_t msglen, + bool need_comp, uint64_t transaction_id) +{ + ssize_t ret =3D 0; + vmbus_packet_hdr hdr; + uint32_t totlen; + VMBusSendRingBuf *ringbuf =3D &chan->send_ringbuf; + + if (!vmbus_channel_is_open(chan)) { + return -EINVAL; + } + + totlen =3D vmbus_pkt_hdr_set_offsets(&hdr, desclen, msglen); + hdr.type =3D pkt_type; + hdr.flags =3D need_comp ? VMBUS_PACKET_FLAG_REQUEST_COMPLETION : 0; + hdr.transaction_id =3D transaction_id; + + assert(totlen <=3D ringbuf->reserved); + + ringbuf_start_io(&ringbuf->common); + ringbuf_seek(&ringbuf->common, ringbuf->wr_idx); + ret =3D ringbuf_io(&ringbuf->common, &hdr, sizeof(hdr)); + if (ret < 0) { + goto out; + } + if (desclen) { + assert(desc); + ret =3D ringbuf_io(&ringbuf->common, desc, desclen); + if (ret < 0) { + goto out; + } + ringbuf_seek(&ringbuf->common, + ringbuf->wr_idx + hdr.offset_qwords * sizeof(uint64_t= )); + } + ret =3D ringbuf_io(&ringbuf->common, msg, msglen); + if (ret < 0) { + goto out; + } + ringbuf_seek(&ringbuf->common, ringbuf->wr_idx + totlen); + ringbuf->wr_idx =3D ringbuf_tell(&ringbuf->common); + ret =3D 0; +out: + ringbuf_end_io(&ringbuf->common); + if (ret) { + return ret; + } + return ringbuf_send_update_idx(chan); +} + +ssize_t vmbus_channel_send_completion(VMBusChanReq *req, + void *msg, uint32_t msglen) +{ + assert(req->need_comp); + return vmbus_channel_send(req->chan, VMBUS_PACKET_COMP, NULL, 0, + msg, msglen, false, req->transaction_id); +} + +static int sgl_from_gpa_ranges(QEMUSGList *sgl, VMBusDevice *dev, + VMBusRingBufCommon *ringbuf, uint32_t len) +{ + int ret; + vmbus_pkt_gpa_direct hdr; + hwaddr curaddr =3D 0; + hwaddr curlen =3D 0; + int num; + + if (len < sizeof(hdr)) { + return -EIO; + } + ret =3D ringbuf_io(ringbuf, &hdr, sizeof(hdr)); + if (ret < 0) { + return ret; + } + len -=3D sizeof(hdr); + + num =3D (len - hdr.rangecount * sizeof(vmbus_gpa_range)) / sizeof(uint= 64_t); + if (num < 0) { + return -EIO; + } + qemu_sglist_init(sgl, DEVICE(dev), num, ringbuf->as); + + for (; hdr.rangecount; hdr.rangecount--) { + vmbus_gpa_range range; + + if (len < sizeof(range)) { + goto eio; + } + ret =3D ringbuf_io(ringbuf, &range, sizeof(range)); + if (ret < 0) { + goto err; + } + len -=3D sizeof(range); + + if (range.byte_offset & TARGET_PAGE_MASK) { + goto eio; + } + + for (; range.byte_count; range.byte_offset =3D 0) { + uint64_t paddr; + uint32_t plen =3D MIN(range.byte_count, + TARGET_PAGE_SIZE - range.byte_offset); + + if (len < sizeof(uint64_t)) { + goto eio; + } + ret =3D ringbuf_io(ringbuf, &paddr, sizeof(paddr)); + if (ret < 0) { + goto err; + } + len -=3D sizeof(uint64_t); + paddr <<=3D TARGET_PAGE_BITS; + paddr |=3D range.byte_offset; + range.byte_count -=3D plen; + + if (curaddr + curlen =3D=3D paddr) { + /* consecutive fragments - join */ + curlen +=3D plen; + } else { + if (curlen) { + qemu_sglist_add(sgl, curaddr, curlen); + } + + curaddr =3D paddr; + curlen =3D plen; + } + } + } + + if (curlen) { + qemu_sglist_add(sgl, curaddr, curlen); + } + + return 0; +eio: + ret =3D -EIO; +err: + qemu_sglist_destroy(sgl); + return ret; +} + +static VMBusChanReq *vmbus_alloc_req(VMBusChannel *chan, + uint32_t size, uint16_t pkt_type, + uint32_t msglen, uint64_t transaction= _id, + bool need_comp) +{ + VMBusChanReq *req; + uint32_t msgoff =3D QEMU_ALIGN_UP(size, __alignof__(*req->msg)); + uint32_t totlen =3D msgoff + msglen; + + req =3D g_malloc0(totlen); + req->chan =3D chan; + req->pkt_type =3D pkt_type; + req->msg =3D (void *)req + msgoff; + req->msglen =3D msglen; + req->transaction_id =3D transaction_id; + req->need_comp =3D need_comp; + return req; +} + +int vmbus_channel_recv_start(VMBusChannel *chan) +{ + VMBusRecvRingBuf *ringbuf =3D &chan->recv_ringbuf; + vmbus_ring_buffer *rb; + + rb =3D ringbuf_map_hdr(&ringbuf->common); + if (!rb) { + return -EFAULT; + } + ringbuf->last_seen_wr_idx =3D rb->write_index; + ringbuf_unmap_hdr(&ringbuf->common, rb, false); + + if (ringbuf->last_seen_wr_idx >=3D ringbuf->common.len) { + return -EOVERFLOW; + } + + /* prevent reorder of the following data operation with write_index re= ad */ + smp_mb(); /* barrier pair [C] */ + return 0; +} + +void *vmbus_channel_recv_peek(VMBusChannel *chan, uint32_t size) +{ + VMBusRecvRingBuf *ringbuf =3D &chan->recv_ringbuf; + vmbus_packet_hdr hdr =3D {}; + VMBusChanReq *req; + uint32_t avail; + uint32_t totlen, pktlen, msglen, msgoff, desclen; + + assert(size >=3D sizeof(*req)); + + /* safe as last_seen_wr_idx is validated in vmbus_channel_recv_start */ + avail =3D rb_idx_delta(ringbuf->rd_idx, ringbuf->last_seen_wr_idx, + ringbuf->common.len, true); + if (avail < sizeof(hdr)) { + return NULL; + } + + ringbuf_seek(&ringbuf->common, ringbuf->rd_idx); + if (ringbuf_io(&ringbuf->common, &hdr, sizeof(hdr)) < 0) { + return NULL; + } + + pktlen =3D hdr.len_qwords * sizeof(uint64_t); + totlen =3D pktlen + VMBUS_PKT_TRAILER; + if (totlen > avail) { + return NULL; + } + + msgoff =3D hdr.offset_qwords * sizeof(uint64_t); + if (msgoff > pktlen || msgoff < sizeof(hdr)) { + error_report("%s: malformed packet: %u %u", __func__, msgoff, pktl= en); + return NULL; + } + + msglen =3D pktlen - msgoff; + + req =3D vmbus_alloc_req(chan, size, hdr.type, msglen, hdr.transaction_= id, + hdr.flags & VMBUS_PACKET_FLAG_REQUEST_COMPLETION= ); + + switch (hdr.type) { + case VMBUS_PACKET_DATA_USING_GPA_DIRECT: + desclen =3D msgoff - sizeof(hdr); + if (sgl_from_gpa_ranges(&req->sgl, chan->dev, &ringbuf->common, + desclen) < 0) { + error_report("%s: failed to convert GPA ranges to SGL", __func= __); + goto free_req; + } + break; + case VMBUS_PACKET_DATA_INBAND: + case VMBUS_PACKET_COMP: + break; + default: + error_report("%s: unexpected msg type: %x", __func__, hdr.type); + goto free_req; + } + + ringbuf_seek(&ringbuf->common, ringbuf->rd_idx + msgoff); + if (ringbuf_io(&ringbuf->common, req->msg, msglen) < 0) { + goto free_req; + } + ringbuf_seek(&ringbuf->common, ringbuf->rd_idx + totlen); + + return req; +free_req: + vmbus_free_req(req); + return NULL; +} + +void vmbus_channel_recv_pop(VMBusChannel *chan) +{ + VMBusRecvRingBuf *ringbuf =3D &chan->recv_ringbuf; + ringbuf->rd_idx =3D ringbuf_tell(&ringbuf->common); +} + +ssize_t vmbus_channel_recv_done(VMBusChannel *chan) +{ + VMBusRecvRingBuf *ringbuf =3D &chan->recv_ringbuf; + vmbus_ring_buffer *rb; + uint32_t read; + + read =3D rb_idx_delta(ringbuf->last_rd_idx, ringbuf->rd_idx, + ringbuf->common.len, true); + if (!read) { + return 0; + } + + rb =3D ringbuf_map_hdr(&ringbuf->common); + if (!rb) { + return -EFAULT; + } + + /* prevent reorder with the data operation and packet read */ + smp_mb(); /* barrier pair [B] */ + rb->read_index =3D ringbuf->rd_idx; + + /* prevent reorder of the following pending_send_sz read */ + smp_mb(); /* barrier pair [A] */ + + if (rb->interrupt_mask) { + goto out; + } + + if (rb->feature_bits & VMBUS_RING_BUFFER_FEAT_PENDING_SZ) { + uint32_t wr_idx, wr_avail; + uint32_t wanted =3D rb->pending_send_sz; + + if (!wanted) { + goto out; + } + + /* prevent reorder with pending_send_sz read */ + smp_rmb(); /* barrier pair [D] */ + wr_idx =3D rb->write_index; + + wr_avail =3D rb_idx_delta(wr_idx, ringbuf->rd_idx, ringbuf->common= .len, + true); + + /* the producer wasn't blocked on the consumer state */ + if (wr_avail >=3D read + wanted) { + goto out; + } + /* there's not enough space for the producer to make progress */ + if (wr_avail < wanted) { + goto out; + } + } + + vmbus_channel_notify_guest(chan); +out: + ringbuf_unmap_hdr(&ringbuf->common, rb, true); + ringbuf->last_rd_idx =3D ringbuf->rd_idx; + return read; +} + +void vmbus_free_req(void *req) +{ + VMBusChanReq *r =3D req; + + if (!req) { + return; + } + + if (r->sgl.dev) { + qemu_sglist_destroy(&r->sgl); + } + g_free(req); +} + +static void channel_event_cb(EventNotifier *e) +{ + VMBusChannel *chan =3D container_of(e, VMBusChannel, notifier); + if (event_notifier_test_and_clear(e)) { + /* + * All receives are supposed to happen within the device worker, so + * bracket it with ringbuf_start/end_io on the receive ringbuffer,= and + * potentially reuse the cached mapping throughout the worker. + * Can't do this for sends as they may happen outside the device + * worker. + */ + VMBusRecvRingBuf *ringbuf =3D &chan->recv_ringbuf; + ringbuf_start_io(&ringbuf->common); + chan->notify_cb(chan); + ringbuf_end_io(&ringbuf->common); + + } +} + +static int alloc_chan_id(VMBus *vmbus) +{ + int ret; + + ret =3D find_next_zero_bit(vmbus->chanid_bitmap, VMBUS_CHANID_COUNT, 0= ); + if (ret =3D=3D VMBUS_CHANID_COUNT) { + return -ENOMEM; + } + return ret + VMBUS_FIRST_CHANID; +} + +static int register_chan_id(VMBusChannel *chan) +{ + return test_and_set_bit(chan->id - VMBUS_FIRST_CHANID, + chan->vmbus->chanid_bitmap) ? -EEXIST : 0; +} + +static void unregister_chan_id(VMBusChannel *chan) +{ + clear_bit(chan->id - VMBUS_FIRST_CHANID, chan->vmbus->chanid_bitmap); +} + +static uint32_t chan_connection_id(VMBusChannel *chan) +{ + return VMBUS_CHAN_CONNECTION_OFFSET + chan->id; +} + +static void init_channel(VMBus *vmbus, VMBusDevice *dev, VMBusDeviceClass = *vdc, + VMBusChannel *chan, uint16_t idx, Error **errp) +{ + int res; + + chan->dev =3D dev; + chan->notify_cb =3D vdc->chan_notify_cb; + chan->subchan_idx =3D idx; + chan->vmbus =3D vmbus; + + res =3D alloc_chan_id(vmbus); + if (res < 0) { + error_setg(errp, "no spare channel id"); + return; + } + chan->id =3D res; + register_chan_id(chan); + + /* + * The guest drivers depend on the device subchannels (idx #1+) to be + * offered after the primary channel (idx #0) of that device. To ensu= re + * that, record the channels on the channel list in the order they app= ear + * within the device. + */ + QTAILQ_INSERT_TAIL(&vmbus->channel_list, chan, link); +} + +static void deinit_channel(VMBusChannel *chan) +{ + assert(chan->state =3D=3D VMCHAN_INIT); + QTAILQ_REMOVE(&chan->vmbus->channel_list, chan, link); + unregister_chan_id(chan); +} + +static void create_channels(VMBus *vmbus, VMBusDevice *dev, Error **errp) +{ + uint16_t i; + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(dev); + Error *err =3D NULL; + + dev->num_channels =3D vdc->num_channels ? vdc->num_channels(dev) : 1; + if (dev->num_channels < 1) { + error_setg(&err, "invalid #channels: %u", dev->num_channels); + goto error_out; + } + + dev->channels =3D g_new0(VMBusChannel, dev->num_channels); + for (i =3D 0; i < dev->num_channels; i++) { + init_channel(vmbus, dev, vdc, &dev->channels[i], i, &err); + if (err) { + goto err_init; + } + } + + return; + +err_init: + while (i--) { + deinit_channel(&dev->channels[i]); + } +error_out: + error_propagate(errp, err); +} + +static void free_channels(VMBusDevice *dev) +{ + uint16_t i; + for (i =3D 0; i < dev->num_channels; i++) { + deinit_channel(&dev->channels[i]); + } + g_free(dev->channels); +} + +static HvSintRoute *make_sint_route(VMBus *vmbus, uint32_t vp_index) +{ + VMBusChannel *chan; + + if (vp_index =3D=3D vmbus->target_vp) { + hyperv_sint_route_ref(vmbus->sint_route); + return vmbus->sint_route; + } + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->target_vp =3D=3D vp_index && vmbus_channel_is_open(chan)= ) { + hyperv_sint_route_ref(chan->notify_route); + return chan->notify_route; + } + } + + return hyperv_sint_route_new(vp_index, VMBUS_SINT, NULL, NULL); +} + +static void open_channel(VMBusChannel *chan) +{ + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(chan->dev); + + chan->gpadl =3D vmbus_get_gpadl(chan, chan->ringbuf_gpadl); + if (!chan->gpadl) { + return; + } + + if (ringbufs_init(chan)) { + goto put_gpadl; + } + + if (event_notifier_init(&chan->notifier, 0)) { + goto put_gpadl; + } + + event_notifier_set_handler(&chan->notifier, channel_event_cb); + + if (hyperv_set_event_flag_handler(chan_connection_id(chan), + &chan->notifier)) { + goto cleanup_notifier; + } + + chan->notify_route =3D make_sint_route(chan->vmbus, chan->target_vp); + if (!chan->notify_route) { + goto clear_event_flag_handler; + } + + if (vdc->open_channel && vdc->open_channel(chan)) { + goto unref_sint_route; + } + + chan->is_open =3D true; + return; + +unref_sint_route: + hyperv_sint_route_unref(chan->notify_route); +clear_event_flag_handler: + hyperv_set_event_flag_handler(chan_connection_id(chan), NULL); +cleanup_notifier: + event_notifier_set_handler(&chan->notifier, NULL); + event_notifier_cleanup(&chan->notifier); +put_gpadl: + vmbus_put_gpadl(chan->gpadl); +} + +static void close_channel(VMBusChannel *chan) +{ + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(chan->dev); + + if (!chan->is_open) { + return; + } + + if (vdc->close_channel) { + vdc->close_channel(chan); + } + + hyperv_sint_route_unref(chan->notify_route); + hyperv_set_event_flag_handler(chan_connection_id(chan), NULL); + event_notifier_set_handler(&chan->notifier, NULL); + event_notifier_cleanup(&chan->notifier); + vmbus_put_gpadl(chan->gpadl); + chan->is_open =3D false; +} + +static int channel_post_load(void *opaque, int version_id) +{ + VMBusChannel *chan =3D opaque; + + return register_chan_id(chan); +} + +static const VMStateDescription vmstate_channel =3D { + .name =3D "vmbus/channel", + .version_id =3D 0, + .minimum_version_id =3D 0, + .post_load =3D channel_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(id, VMBusChannel), + VMSTATE_UINT16(subchan_idx, VMBusChannel), + VMSTATE_UINT32(open_id, VMBusChannel), + VMSTATE_UINT32(target_vp, VMBusChannel), + VMSTATE_UINT32(ringbuf_gpadl, VMBusChannel), + VMSTATE_UINT32(ringbuf_send_offset, VMBusChannel), + VMSTATE_UINT8(offer_state, VMBusChannel), + VMSTATE_UINT8(state, VMBusChannel), + VMSTATE_END_OF_LIST() + } +}; + +static VMBusChannel *find_channel(VMBus *vmbus, uint32_t id) +{ + VMBusChannel *chan; + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->id =3D=3D id) { + return chan; + } + } + return NULL; +} + +static int enqueue_incoming_message(VMBus *vmbus, + const struct hyperv_post_message_input= *msg) +{ + int ret =3D 0; + uint8_t idx, prev_size; + + qemu_mutex_lock(&vmbus->rx_queue_lock); + + if (vmbus->rx_queue_size =3D=3D HV_MSG_QUEUE_LEN) { + ret =3D -ENOBUFS; + goto out; + } + + prev_size =3D vmbus->rx_queue_size; + idx =3D (vmbus->rx_queue_head + vmbus->rx_queue_size) % HV_MSG_QUEUE_L= EN; + memcpy(&vmbus->rx_queue[idx], msg, sizeof(*msg)); + vmbus->rx_queue_size++; + + /* only need to resched if the queue was empty before */ + if (!prev_size) { + vmbus_resched(vmbus); + } +out: + qemu_mutex_unlock(&vmbus->rx_queue_lock); + return ret; +} + +static uint16_t vmbus_recv_message(const struct hyperv_post_message_input = *msg, + void *data) +{ + VMBus *vmbus =3D data; + struct vmbus_message_header *vmbus_msg; + + if (msg->message_type !=3D HV_MESSAGE_VMBUS) { + return HV_STATUS_INVALID_HYPERCALL_INPUT; + } + + if (msg->payload_size < sizeof(struct vmbus_message_header)) { + return HV_STATUS_INVALID_HYPERCALL_INPUT; + } + + vmbus_msg =3D (struct vmbus_message_header *)msg->payload; + + trace_vmbus_recv_message(vmbus_msg->message_type, msg->payload_size); + + if (vmbus_msg->message_type =3D=3D VMBUS_MSG_INVALID || + vmbus_msg->message_type >=3D VMBUS_MSG_COUNT) { + error_report("vmbus: unknown message type %#x", + vmbus_msg->message_type); + return HV_STATUS_INVALID_HYPERCALL_INPUT; + } + + if (enqueue_incoming_message(vmbus, msg)) { + return HV_STATUS_INSUFFICIENT_BUFFERS; + } + return HV_STATUS_SUCCESS; +} + +static bool vmbus_initialized(VMBus *vmbus) +{ + return vmbus->version > 0 && vmbus->version <=3D VMBUS_VERSION_CURRENT; +} + +static void vmbus_reset_all(VMBus *vmbus) +{ + qbus_reset_all(BUS(vmbus)); +} + +static void post_msg(VMBus *vmbus, void *msgdata, uint32_t msglen) +{ + int ret; + struct hyperv_message msg =3D { + .header.message_type =3D HV_MESSAGE_VMBUS, + }; + + assert(!vmbus->msg_in_progress); + assert(msglen <=3D sizeof(msg.payload)); + assert(msglen >=3D sizeof(struct vmbus_message_header)); + + vmbus->msg_in_progress =3D true; + + trace_vmbus_post_msg(((struct vmbus_message_header *)msgdata)->message= _type, + msglen); + + memcpy(msg.payload, msgdata, msglen); + msg.header.payload_size =3D ROUND_UP(msglen, VMBUS_MESSAGE_SIZE_ALIGN); + + ret =3D hyperv_post_msg(vmbus->sint_route, &msg); + if (ret =3D=3D 0 || ret =3D=3D -EAGAIN) { + return; + } + + error_report("message delivery fatal failure: %d; aborting vmbus", ret= ); + vmbus_reset_all(vmbus); +} + +static int vmbus_init(VMBus *vmbus) +{ + if (vmbus->target_vp !=3D (uint32_t)-1) { + vmbus->sint_route =3D hyperv_sint_route_new(vmbus->target_vp, VMBU= S_SINT, + vmbus_msg_cb, vmbus); + if (!vmbus->sint_route) { + error_report("failed to set up SINT route"); + return -ENOMEM; + } + } + return 0; +} + +static void vmbus_deinit(VMBus *vmbus) +{ + VMBusGpadl *gpadl, *tmp_gpadl; + VMBusChannel *chan; + + QTAILQ_FOREACH_SAFE(gpadl, &vmbus->gpadl_list, link, tmp_gpadl) { + if (gpadl->state =3D=3D VMGPADL_TORNDOWN) { + continue; + } + vmbus_put_gpadl(gpadl); + } + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + chan->offer_state =3D VMOFFER_INIT; + } + + hyperv_sint_route_unref(vmbus->sint_route); + vmbus->sint_route =3D NULL; + vmbus->int_page_gpa =3D 0; + vmbus->target_vp =3D (uint32_t)-1; + vmbus->version =3D 0; + vmbus->state =3D VMBUS_LISTEN; + vmbus->msg_in_progress =3D false; +} + +static void handle_initiate_contact(VMBus *vmbus, + vmbus_message_initiate_contact *msg, + uint32_t msglen) +{ + if (msglen < sizeof(*msg)) { + return; + } + + trace_vmbus_initiate_contact(msg->version_requested >> 16, + msg->version_requested & 0xffff, + msg->target_vcpu, msg->monitor_page1, + msg->monitor_page2, msg->interrupt_page); + + /* + * Reset vmbus on INITIATE_CONTACT regardless of its previous state. + * Useful, in particular, with vmbus-aware BIOS which can't shut vmbus= down + * before handing over to OS loader. + */ + vmbus_reset_all(vmbus); + + vmbus->target_vp =3D msg->target_vcpu; + vmbus->version =3D msg->version_requested; + if (vmbus->version < VMBUS_VERSION_WIN8) { + /* linux passes interrupt page even when it doesn't need it */ + vmbus->int_page_gpa =3D msg->interrupt_page; + } + vmbus->state =3D VMBUS_HANDSHAKE; + + if (vmbus_init(vmbus)) { + error_report("failed to init vmbus; aborting"); + vmbus_deinit(vmbus); + return; + } +} + +static void send_handshake(VMBus *vmbus) +{ + struct vmbus_message_version_response msg =3D { + .header.message_type =3D VMBUS_MSG_VERSION_RESPONSE, + .version_supported =3D vmbus_initialized(vmbus), + }; + + post_msg(vmbus, &msg, sizeof(msg)); +} + +static void handle_request_offers(VMBus *vmbus, void *msgdata, uint32_t ms= glen) +{ + VMBusChannel *chan; + + if (!vmbus_initialized(vmbus)) { + return; + } + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->offer_state =3D=3D VMOFFER_INIT) { + chan->offer_state =3D VMOFFER_SENDING; + break; + } + } + + vmbus->state =3D VMBUS_OFFER; +} + +static void send_offer(VMBus *vmbus) +{ + VMBusChannel *chan; + struct vmbus_message_header alloffers_msg =3D { + .message_type =3D VMBUS_MSG_ALLOFFERS_DELIVERED, + }; + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->offer_state =3D=3D VMOFFER_SENDING) { + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(chan->dev); + /* Hyper-V wants LE GUIDs */ + QemuUUID classid =3D qemu_uuid_bswap(vdc->classid); + QemuUUID instanceid =3D qemu_uuid_bswap(chan->dev->instanceid); + struct vmbus_message_offer_channel msg =3D { + .header.message_type =3D VMBUS_MSG_OFFERCHANNEL, + .child_relid =3D chan->id, + .connection_id =3D chan_connection_id(chan), + .channel_flags =3D vdc->channel_flags, + .mmio_size_mb =3D vdc->mmio_size_mb, + .sub_channel_index =3D vmbus_channel_idx(chan), + .interrupt_flags =3D VMBUS_OFFER_INTERRUPT_DEDICATED, + }; + + memcpy(msg.type_uuid, &classid, sizeof(classid)); + memcpy(msg.instance_uuid, &instanceid, sizeof(instanceid)); + + trace_vmbus_send_offer(chan->id, chan->dev); + + post_msg(vmbus, &msg, sizeof(msg)); + return; + } + } + + /* no more offers, send terminator message */ + trace_vmbus_terminate_offers(); + post_msg(vmbus, &alloffers_msg, sizeof(alloffers_msg)); +} + +static bool complete_offer(VMBus *vmbus) +{ + VMBusChannel *chan; + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->offer_state =3D=3D VMOFFER_SENDING) { + chan->offer_state =3D VMOFFER_SENT; + goto next_offer; + } + } + /* + * no transitioning channels found so this is completing the terminator + * message, and vmbus can move to the next state + */ + return true; + +next_offer: + /* try to mark another channel for offering */ + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->offer_state =3D=3D VMOFFER_INIT) { + chan->offer_state =3D VMOFFER_SENDING; + break; + } + } + /* + * if an offer has been sent there are more offers or the terminator y= et to + * send, so no state transition for vmbus + */ + return false; +} + + +static void handle_gpadl_header(VMBus *vmbus, vmbus_message_gpadl_header *= msg, + uint32_t msglen) +{ + VMBusGpadl *gpadl; + uint32_t num_gfns, i; + + /* must include at least one gpa range */ + if (msglen < sizeof(*msg) + sizeof(msg->range[0]) || + !vmbus_initialized(vmbus)) { + return; + } + + num_gfns =3D (msg->range_buflen - msg->rangecount * sizeof(msg->range[= 0])) / + sizeof(msg->range[0].pfn_array[0]); + + trace_vmbus_gpadl_header(msg->gpadl_id, num_gfns); + + /* + * In theory the GPADL_HEADER message can define a GPADL with multiple= GPA + * ranges each with arbitrary size and alignment. However in practice= only + * single-range page-aligned GPADLs have been observed so just ignore + * anything else and simplify things greatly. + */ + if (msg->rangecount !=3D 1 || msg->range[0].byte_offset || + (msg->range[0].byte_count !=3D (num_gfns << TARGET_PAGE_BITS))) { + return; + } + + /* ignore requests to create already existing GPADLs */ + if (find_gpadl(vmbus, msg->gpadl_id)) { + return; + } + + gpadl =3D create_gpadl(vmbus, msg->gpadl_id, msg->child_relid, num_gfn= s); + + for (i =3D 0; i < num_gfns && + (void *)&msg->range[0].pfn_array[i + 1] <=3D (void *)msg + msglen; + i++) { + gpadl->gfns[gpadl->seen_gfns++] =3D msg->range[0].pfn_array[i]; + } + + if (gpadl_full(gpadl)) { + vmbus->state =3D VMBUS_CREATE_GPADL; + } +} + +static void handle_gpadl_body(VMBus *vmbus, vmbus_message_gpadl_body *msg, + uint32_t msglen) +{ + VMBusGpadl *gpadl; + uint32_t num_gfns_left, i; + + if (msglen < sizeof(*msg) || !vmbus_initialized(vmbus)) { + return; + } + + trace_vmbus_gpadl_body(msg->gpadl_id); + + gpadl =3D find_gpadl(vmbus, msg->gpadl_id); + if (!gpadl) { + return; + } + + num_gfns_left =3D gpadl->num_gfns - gpadl->seen_gfns; + assert(num_gfns_left); + + for (i =3D 0; i < num_gfns_left && + (void *)&msg->pfn_array[i + 1] <=3D (void *)msg + msglen; i++) { + gpadl->gfns[gpadl->seen_gfns++] =3D msg->pfn_array[i]; + } + + if (gpadl_full(gpadl)) { + vmbus->state =3D VMBUS_CREATE_GPADL; + } +} + +static void send_create_gpadl(VMBus *vmbus) +{ + VMBusGpadl *gpadl; + + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + if (gpadl_full(gpadl) && gpadl->state =3D=3D VMGPADL_INIT) { + struct vmbus_message_gpadl_created msg =3D { + .header.message_type =3D VMBUS_MSG_GPADL_CREATED, + .gpadl_id =3D gpadl->id, + .child_relid =3D gpadl->child_relid, + }; + + trace_vmbus_gpadl_created(gpadl->id); + post_msg(vmbus, &msg, sizeof(msg)); + return; + } + } + + assert(false); +} + +static bool complete_create_gpadl(VMBus *vmbus) +{ + VMBusGpadl *gpadl; + + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + if (gpadl_full(gpadl) && gpadl->state =3D=3D VMGPADL_INIT) { + gpadl->state =3D VMGPADL_ALIVE; + + return true; + } + } + + assert(false); + return false; +} + +static void handle_gpadl_teardown(VMBus *vmbus, + vmbus_message_gpadl_teardown *msg, + uint32_t msglen) +{ + VMBusGpadl *gpadl; + + if (msglen < sizeof(*msg) || !vmbus_initialized(vmbus)) { + return; + } + + trace_vmbus_gpadl_teardown(msg->gpadl_id); + + gpadl =3D find_gpadl(vmbus, msg->gpadl_id); + if (!gpadl || gpadl->state =3D=3D VMGPADL_TORNDOWN) { + return; + } + + gpadl->state =3D VMGPADL_TEARINGDOWN; + vmbus->state =3D VMBUS_TEARDOWN_GPADL; +} + +static void send_teardown_gpadl(VMBus *vmbus) +{ + VMBusGpadl *gpadl; + + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + if (gpadl->state =3D=3D VMGPADL_TEARINGDOWN) { + struct vmbus_message_gpadl_torndown msg =3D { + .header.message_type =3D VMBUS_MSG_GPADL_TORNDOWN, + .gpadl_id =3D gpadl->id, + }; + + trace_vmbus_gpadl_torndown(gpadl->id); + post_msg(vmbus, &msg, sizeof(msg)); + return; + } + } + + assert(false); +} + +static bool complete_teardown_gpadl(VMBus *vmbus) +{ + VMBusGpadl *gpadl; + + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + if (gpadl->state =3D=3D VMGPADL_TEARINGDOWN) { + gpadl->state =3D VMGPADL_TORNDOWN; + vmbus_put_gpadl(gpadl); + return true; + } + } + + assert(false); + return false; +} + +static void handle_open_channel(VMBus *vmbus, vmbus_message_open_channel *= msg, + uint32_t msglen) +{ + VMBusChannel *chan; + + if (msglen < sizeof(*msg) || !vmbus_initialized(vmbus)) { + return; + } + + trace_vmbus_open_channel(msg->child_relid, msg->ring_buffer_gpadl_id, + msg->target_vp); + chan =3D find_channel(vmbus, msg->child_relid); + if (!chan || chan->state !=3D VMCHAN_INIT) { + return; + } + + chan->ringbuf_gpadl =3D msg->ring_buffer_gpadl_id; + chan->ringbuf_send_offset =3D msg->ring_buffer_offset; + chan->target_vp =3D msg->target_vp; + chan->open_id =3D msg->open_id; + + open_channel(chan); + + chan->state =3D VMCHAN_OPENING; + vmbus->state =3D VMBUS_OPEN_CHANNEL; +} + +static void send_open_channel(VMBus *vmbus) +{ + VMBusChannel *chan; + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->state =3D=3D VMCHAN_OPENING) { + struct vmbus_message_open_result msg =3D { + .header.message_type =3D VMBUS_MSG_OPENCHANNEL_RESULT, + .child_relid =3D chan->id, + .open_id =3D chan->open_id, + .status =3D !vmbus_channel_is_open(chan), + }; + + trace_vmbus_channel_open(chan->id, msg.status); + post_msg(vmbus, &msg, sizeof(msg)); + return; + } + } + + assert(false); +} + +static bool complete_open_channel(VMBus *vmbus) +{ + VMBusChannel *chan; + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (chan->state =3D=3D VMCHAN_OPENING) { + if (vmbus_channel_is_open(chan)) { + chan->state =3D VMCHAN_OPEN; + /* + * simulate guest notification of ringbuffer space made + * available, for the channel protocols where the host + * initiates the communication + */ + vmbus_channel_notify_host(chan); + } else { + chan->state =3D VMCHAN_INIT; + } + return true; + } + } + + assert(false); + return false; +} + +static void vdev_reset_on_close(VMBusDevice *vdev) +{ + uint16_t i; + + for (i =3D 0; i < vdev->num_channels; i++) { + if (vmbus_channel_is_open(&vdev->channels[i])) { + return; + } + } + + /* all channels closed -- reset device */ + qdev_reset_all(DEVICE(vdev)); +} + +static void handle_close_channel(VMBus *vmbus, vmbus_message_close_channel= *msg, + uint32_t msglen) +{ + VMBusChannel *chan; + + if (msglen < sizeof(*msg) || !vmbus_initialized(vmbus)) { + return; + } + + trace_vmbus_close_channel(msg->child_relid); + + chan =3D find_channel(vmbus, msg->child_relid); + if (!chan) { + return; + } + + close_channel(chan); + chan->state =3D VMCHAN_INIT; + + vdev_reset_on_close(chan->dev); +} + +static void handle_unload(VMBus *vmbus, void *msg, uint32_t msglen) +{ + vmbus->state =3D VMBUS_UNLOAD; +} + +static void send_unload(VMBus *vmbus) +{ + vmbus_message_header msg =3D { + .message_type =3D VMBUS_MSG_UNLOAD_RESPONSE, + }; + + qemu_mutex_lock(&vmbus->rx_queue_lock); + vmbus->rx_queue_size =3D 0; + qemu_mutex_unlock(&vmbus->rx_queue_lock); + + post_msg(vmbus, &msg, sizeof(msg)); + return; +} + +static bool complete_unload(VMBus *vmbus) +{ + vmbus_reset_all(vmbus); + return true; +} + +static void process_message(VMBus *vmbus) +{ + struct hyperv_post_message_input *hv_msg; + struct vmbus_message_header *msg; + void *msgdata; + uint32_t msglen; + + qemu_mutex_lock(&vmbus->rx_queue_lock); + + if (!vmbus->rx_queue_size) { + goto unlock; + } + + hv_msg =3D &vmbus->rx_queue[vmbus->rx_queue_head]; + msglen =3D hv_msg->payload_size; + if (msglen < sizeof(*msg)) { + goto out; + } + msgdata =3D hv_msg->payload; + msg =3D (struct vmbus_message_header *)msgdata; + + trace_vmbus_process_incoming_message(msg->message_type); + + switch (msg->message_type) { + case VMBUS_MSG_INITIATE_CONTACT: + handle_initiate_contact(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_REQUESTOFFERS: + handle_request_offers(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_GPADL_HEADER: + handle_gpadl_header(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_GPADL_BODY: + handle_gpadl_body(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_GPADL_TEARDOWN: + handle_gpadl_teardown(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_OPENCHANNEL: + handle_open_channel(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_CLOSECHANNEL: + handle_close_channel(vmbus, msgdata, msglen); + break; + case VMBUS_MSG_UNLOAD: + handle_unload(vmbus, msgdata, msglen); + break; + default: + error_report("unknown message type %#x", msg->message_type); + break; + } + +out: + vmbus->rx_queue_size--; + vmbus->rx_queue_head++; + vmbus->rx_queue_head %=3D HV_MSG_QUEUE_LEN; + + vmbus_resched(vmbus); +unlock: + qemu_mutex_unlock(&vmbus->rx_queue_lock); +} + +static const struct { + void (*run)(VMBus *vmbus); + bool (*complete)(VMBus *vmbus); +} state_runner[] =3D { + [VMBUS_LISTEN] =3D {process_message, NULL}, + [VMBUS_HANDSHAKE] =3D {send_handshake, NULL}, + [VMBUS_OFFER] =3D {send_offer, complete_offer}, + [VMBUS_CREATE_GPADL] =3D {send_create_gpadl, complete_create_gpadl= }, + [VMBUS_TEARDOWN_GPADL] =3D {send_teardown_gpadl, complete_teardown_gpa= dl}, + [VMBUS_OPEN_CHANNEL] =3D {send_open_channel, complete_open_channel= }, + [VMBUS_UNLOAD] =3D {send_unload, complete_unload}, +}; + +static void vmbus_do_run(VMBus *vmbus) +{ + if (vmbus->msg_in_progress) { + return; + } + + assert(vmbus->state < VMBUS_STATE_MAX); + assert(state_runner[vmbus->state].run); + state_runner[vmbus->state].run(vmbus); +} + +static void vmbus_run(void *opaque) +{ + VMBus *vmbus =3D opaque; + + /* make sure no recursion happens (e.g. due to recursive aio_poll()) */ + if (vmbus->in_progress) { + return; + } + + vmbus->in_progress =3D true; + /* + * FIXME: if vmbus_resched() is called from within vmbus_do_run(), it + * should go *after* the code that can result in aio_poll; otherwise + * reschedules can be missed. No idea how to enforce that. + */ + vmbus_do_run(vmbus); + vmbus->in_progress =3D false; +} + +static void vmbus_msg_cb(void *data, int status) +{ + VMBus *vmbus =3D data; + bool (*complete)(VMBus *vmbus); + + assert(vmbus->msg_in_progress); + + trace_vmbus_msg_cb(status); + + if (status =3D=3D -EAGAIN) { + goto out; + } + if (status) { + error_report("message delivery fatal failure: %d; aborting vmbus", + status); + vmbus_reset_all(vmbus); + return; + } + + assert(vmbus->state < VMBUS_STATE_MAX); + complete =3D state_runner[vmbus->state].complete; + if (!complete || complete(vmbus)) { + vmbus->state =3D VMBUS_LISTEN; + } +out: + vmbus->msg_in_progress =3D false; + vmbus_resched(vmbus); +} + +static void vmbus_resched(VMBus *vmbus) +{ + aio_bh_schedule_oneshot(qemu_get_aio_context(), vmbus_run, vmbus); +} + +static void vmbus_signal_event(EventNotifier *e) +{ + VMBusChannel *chan; + VMBus *vmbus =3D container_of(e, VMBus, notifier); + unsigned long *int_map; + hwaddr addr, len; + bool is_dirty =3D false; + + if (!event_notifier_test_and_clear(e)) { + return; + } + + trace_vmbus_signal_event(); + + if (!vmbus->int_page_gpa) { + return; + } + + addr =3D vmbus->int_page_gpa + TARGET_PAGE_SIZE / 2; + len =3D TARGET_PAGE_SIZE / 2; + int_map =3D cpu_physical_memory_map(addr, &len, 1); + if (len !=3D TARGET_PAGE_SIZE / 2) { + goto unmap; + } + + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + if (bitmap_test_and_clear_atomic(int_map, chan->id, 1)) { + if (!vmbus_channel_is_open(chan)) { + continue; + } + vmbus_channel_notify_host(chan); + is_dirty =3D true; + } + } + +unmap: + cpu_physical_memory_unmap(int_map, len, 1, is_dirty); +} + +static void vmbus_dev_realize(DeviceState *dev, Error **errp) +{ + VMBusDevice *vdev =3D VMBUS_DEVICE(dev); + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(vdev); + VMBus *vmbus =3D VMBUS(qdev_get_parent_bus(dev)); + BusChild *child; + Error *err =3D NULL; + char idstr[UUID_FMT_LEN + 1]; + + assert(!qemu_uuid_is_null(&vdev->instanceid)); + + /* Check for instance id collision for this class id */ + QTAILQ_FOREACH(child, &BUS(vmbus)->children, sibling) { + VMBusDevice *child_dev =3D VMBUS_DEVICE(child->child); + + if (child_dev =3D=3D vdev) { + continue; + } + + if (qemu_uuid_is_equal(&child_dev->instanceid, &vdev->instanceid))= { + qemu_uuid_unparse(&vdev->instanceid, idstr); + error_setg(&err, "duplicate vmbus device instance id %s", idst= r); + goto error_out; + } + } + + vdev->dma_as =3D &address_space_memory; + + create_channels(vmbus, vdev, &err); + if (err) { + goto error_out; + } + + if (vdc->vmdev_realize) { + vdc->vmdev_realize(vdev, &err); + if (err) { + goto err_vdc_realize; + } + } + return; + +err_vdc_realize: + free_channels(vdev); +error_out: + error_propagate(errp, err); +} + +static void vmbus_dev_reset(DeviceState *dev) +{ + uint16_t i; + VMBusDevice *vdev =3D VMBUS_DEVICE(dev); + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(vdev); + + if (vdev->channels) { + for (i =3D 0; i < vdev->num_channels; i++) { + VMBusChannel *chan =3D &vdev->channels[i]; + close_channel(chan); + chan->state =3D VMCHAN_INIT; + } + } + + if (vdc->vmdev_reset) { + vdc->vmdev_reset(vdev); + } +} + +static void vmbus_dev_unrealize(DeviceState *dev) +{ + VMBusDevice *vdev =3D VMBUS_DEVICE(dev); + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(vdev); + + if (vdc->vmdev_unrealize) { + vdc->vmdev_unrealize(vdev); + } + free_channels(vdev); +} + +static void vmbus_dev_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *kdev =3D DEVICE_CLASS(klass); + kdev->bus_type =3D TYPE_VMBUS; + kdev->realize =3D vmbus_dev_realize; + kdev->unrealize =3D vmbus_dev_unrealize; + kdev->reset =3D vmbus_dev_reset; +} + +static Property vmbus_dev_instanceid =3D + DEFINE_PROP_UUID("instanceid", VMBusDevice, instan= ceid); + +static void vmbus_dev_instance_init(Object *obj) +{ + VMBusDevice *vdev =3D VMBUS_DEVICE(obj); + VMBusDeviceClass *vdc =3D VMBUS_DEVICE_GET_CLASS(vdev); + + if (!qemu_uuid_is_null(&vdc->instanceid)) { + /* Class wants to only have a single instance with a fixed UUID */ + vdev->instanceid =3D vdc->instanceid; + } else { + qdev_property_add_static(DEVICE(vdev), &vmbus_dev_instanceid); + } +} + +const VMStateDescription vmstate_vmbus_dev =3D { + .name =3D TYPE_VMBUS_DEVICE, + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY(instanceid.data, VMBusDevice, 16), + VMSTATE_UINT16(num_channels, VMBusDevice), + VMSTATE_STRUCT_VARRAY_POINTER_UINT16(channels, VMBusDevice, + num_channels, vmstate_channel, + VMBusChannel), + VMSTATE_END_OF_LIST() + } +}; + +/* vmbus generic device base */ +static const TypeInfo vmbus_dev_type_info =3D { + .name =3D TYPE_VMBUS_DEVICE, + .parent =3D TYPE_DEVICE, + .abstract =3D true, + .instance_size =3D sizeof(VMBusDevice), + .class_size =3D sizeof(VMBusDeviceClass), + .class_init =3D vmbus_dev_class_init, + .instance_init =3D vmbus_dev_instance_init, +}; + +static void vmbus_realize(BusState *bus, Error **errp) +{ + int ret =3D 0; + Error *local_err =3D NULL; + VMBus *vmbus =3D VMBUS(bus); + + qemu_mutex_init(&vmbus->rx_queue_lock); + + QTAILQ_INIT(&vmbus->gpadl_list); + QTAILQ_INIT(&vmbus->channel_list); + + ret =3D hyperv_set_msg_handler(VMBUS_MESSAGE_CONNECTION_ID, + vmbus_recv_message, vmbus); + if (ret !=3D 0) { + error_setg(&local_err, "hyperv set message handler failed: %d", re= t); + goto error_out; + } + + ret =3D event_notifier_init(&vmbus->notifier, 0); + if (ret !=3D 0) { + error_setg(&local_err, "event notifier failed to init with %d", re= t); + goto remove_msg_handler; + } + + event_notifier_set_handler(&vmbus->notifier, vmbus_signal_event); + ret =3D hyperv_set_event_flag_handler(VMBUS_EVENT_CONNECTION_ID, + &vmbus->notifier); + if (ret !=3D 0) { + error_setg(&local_err, "hyperv set event handler failed with %d", = ret); + goto clear_event_notifier; + } + + return; + +clear_event_notifier: + event_notifier_cleanup(&vmbus->notifier); +remove_msg_handler: + hyperv_set_msg_handler(VMBUS_MESSAGE_CONNECTION_ID, NULL, NULL); +error_out: + qemu_mutex_destroy(&vmbus->rx_queue_lock); + error_propagate(errp, local_err); +} + +static void vmbus_unrealize(BusState *bus) +{ + VMBus *vmbus =3D VMBUS(bus); + + hyperv_set_msg_handler(VMBUS_MESSAGE_CONNECTION_ID, NULL, NULL); + hyperv_set_event_flag_handler(VMBUS_EVENT_CONNECTION_ID, NULL); + event_notifier_cleanup(&vmbus->notifier); + + qemu_mutex_destroy(&vmbus->rx_queue_lock); +} + +static void vmbus_reset(BusState *bus) +{ + vmbus_deinit(VMBUS(bus)); +} + +static char *vmbus_get_dev_path(DeviceState *dev) +{ + BusState *bus =3D qdev_get_parent_bus(dev); + return qdev_get_dev_path(bus->parent); +} + +static char *vmbus_get_fw_dev_path(DeviceState *dev) +{ + VMBusDevice *vdev =3D VMBUS_DEVICE(dev); + char uuid[UUID_FMT_LEN + 1]; + + qemu_uuid_unparse(&vdev->instanceid, uuid); + return g_strdup_printf("%s@%s", qdev_fw_name(dev), uuid); +} + +static void vmbus_class_init(ObjectClass *klass, void *data) +{ + BusClass *k =3D BUS_CLASS(klass); + + k->get_dev_path =3D vmbus_get_dev_path; + k->get_fw_dev_path =3D vmbus_get_fw_dev_path; + k->realize =3D vmbus_realize; + k->unrealize =3D vmbus_unrealize; + k->reset =3D vmbus_reset; +} + +static int vmbus_pre_load(void *opaque) +{ + VMBusChannel *chan; + VMBus *vmbus =3D VMBUS(opaque); + + /* + * channel IDs allocated by the source will come in the migration stre= am + * for each channel, so clean up the ones allocated at realize + */ + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + unregister_chan_id(chan); + } + + return 0; +} +static int vmbus_post_load(void *opaque, int version_id) +{ + int ret; + VMBus *vmbus =3D VMBUS(opaque); + VMBusGpadl *gpadl; + VMBusChannel *chan; + + ret =3D vmbus_init(vmbus); + if (ret) { + return ret; + } + + QTAILQ_FOREACH(gpadl, &vmbus->gpadl_list, link) { + gpadl->vmbus =3D vmbus; + gpadl->refcount =3D 1; + } + + /* + * reopening channels depends on initialized vmbus so it's done here + * instead of channel_post_load() + */ + QTAILQ_FOREACH(chan, &vmbus->channel_list, link) { + + if (chan->state =3D=3D VMCHAN_OPENING || chan->state =3D=3D VMCHAN= _OPEN) { + open_channel(chan); + } + + if (chan->state !=3D VMCHAN_OPEN) { + continue; + } + + if (!vmbus_channel_is_open(chan)) { + /* reopen failed, abort loading */ + return -1; + } + + /* resume processing on the guest side if it missed the notificati= on */ + hyperv_sint_route_set_sint(chan->notify_route); + /* ditto on the host side */ + vmbus_channel_notify_host(chan); + } + + vmbus_resched(vmbus); + return 0; +} + +static const VMStateDescription vmstate_post_message_input =3D { + .name =3D "vmbus/hyperv_post_message_input", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + /* + * skip connection_id and message_type as they are validated before + * queueing and ignored on dequeueing + */ + VMSTATE_UINT32(payload_size, struct hyperv_post_message_input), + VMSTATE_UINT8_ARRAY(payload, struct hyperv_post_message_input, + HV_MESSAGE_PAYLOAD_SIZE), + VMSTATE_END_OF_LIST() + } +}; + +static bool vmbus_rx_queue_needed(void *opaque) +{ + VMBus *vmbus =3D VMBUS(opaque); + return vmbus->rx_queue_size; +} + +static const VMStateDescription vmstate_rx_queue =3D { + .name =3D "vmbus/rx_queue", + .version_id =3D 0, + .minimum_version_id =3D 0, + .needed =3D vmbus_rx_queue_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(rx_queue_head, VMBus), + VMSTATE_UINT8(rx_queue_size, VMBus), + VMSTATE_STRUCT_ARRAY(rx_queue, VMBus, + HV_MSG_QUEUE_LEN, 0, + vmstate_post_message_input, + struct hyperv_post_message_input), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_vmbus =3D { + .name =3D TYPE_VMBUS, + .version_id =3D 0, + .minimum_version_id =3D 0, + .pre_load =3D vmbus_pre_load, + .post_load =3D vmbus_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(state, VMBus), + VMSTATE_UINT32(version, VMBus), + VMSTATE_UINT32(target_vp, VMBus), + VMSTATE_UINT64(int_page_gpa, VMBus), + VMSTATE_QTAILQ_V(gpadl_list, VMBus, 0, + vmstate_gpadl, VMBusGpadl, link), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_rx_queue, + NULL + } +}; + +static const TypeInfo vmbus_type_info =3D { + .name =3D TYPE_VMBUS, + .parent =3D TYPE_BUS, + .instance_size =3D sizeof(VMBus), + .class_init =3D vmbus_class_init, +}; + +static void vmbus_bridge_realize(DeviceState *dev, Error **errp) +{ + VMBusBridge *bridge =3D VMBUS_BRIDGE(dev); + + /* + * here there's at least one vmbus bridge that is being realized, so + * vmbus_bridge_find can only return NULL if it's not unique + */ + if (!vmbus_bridge_find()) { + error_setg(errp, "there can be at most one %s in the system", + TYPE_VMBUS_BRIDGE); + return; + } + + if (!hyperv_is_synic_enabled()) { + error_report("VMBus requires usable Hyper-V SynIC and VP_INDEX"); + return; + } + + bridge->bus =3D VMBUS(qbus_create(TYPE_VMBUS, dev, "vmbus")); +} + +static char *vmbus_bridge_ofw_unit_address(const SysBusDevice *dev) +{ + /* there can be only one VMBus */ + return g_strdup("0"); +} + +static const VMStateDescription vmstate_vmbus_bridge =3D { + .name =3D TYPE_VMBUS_BRIDGE, + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT_POINTER(bus, VMBusBridge, vmstate_vmbus, VMBus), + VMSTATE_END_OF_LIST() + }, +}; + +static void vmbus_bridge_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *k =3D DEVICE_CLASS(klass); + SysBusDeviceClass *sk =3D SYS_BUS_DEVICE_CLASS(klass); + + k->realize =3D vmbus_bridge_realize; + k->fw_name =3D "vmbus"; + sk->explicit_ofw_unit_address =3D vmbus_bridge_ofw_unit_address; + set_bit(DEVICE_CATEGORY_BRIDGE, k->categories); + k->vmsd =3D &vmstate_vmbus_bridge; + /* override SysBusDevice's default */ + k->user_creatable =3D true; +} + +static const TypeInfo vmbus_bridge_type_info =3D { + .name =3D TYPE_VMBUS_BRIDGE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(VMBusBridge), + .class_init =3D vmbus_bridge_class_init, +}; + +static void vmbus_register_types(void) +{ + type_register_static(&vmbus_bridge_type_info); + type_register_static(&vmbus_dev_type_info); + type_register_static(&vmbus_type_info); +} + +type_init(vmbus_register_types) diff --git a/include/hw/hyperv/vmbus-bridge.h b/include/hw/hyperv/vmbus-bri= dge.h new file mode 100644 index 0000000000..9cc8f780de --- /dev/null +++ b/include/hw/hyperv/vmbus-bridge.h @@ -0,0 +1,32 @@ +/* + * QEMU Hyper-V VMBus root bridge + * + * Copyright (c) 2017-2018 Virtuozzo International GmbH. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_HYPERV_VMBUS_BRIDGE_H +#define HW_HYPERV_VMBUS_BRIDGE_H + +#include "hw/sysbus.h" + +#define TYPE_VMBUS_BRIDGE "vmbus-bridge" + +typedef struct VMBus VMBus; + +typedef struct VMBusBridge { + SysBusDevice parent_obj; + + VMBus *bus; +} VMBusBridge; + +#define VMBUS_BRIDGE(obj) OBJECT_CHECK(VMBusBridge, (obj), TYPE_VMBUS_BRID= GE) + +static inline VMBusBridge *vmbus_bridge_find(void) +{ + return VMBUS_BRIDGE(object_resolve_path_type("", TYPE_VMBUS_BRIDGE, NU= LL)); +} + +#endif diff --git a/include/hw/hyperv/vmbus.h b/include/hw/hyperv/vmbus.h new file mode 100644 index 0000000000..99b647e1d6 --- /dev/null +++ b/include/hw/hyperv/vmbus.h @@ -0,0 +1,227 @@ +/* + * QEMU Hyper-V VMBus + * + * Copyright (c) 2017-2018 Virtuozzo International GmbH. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_HYPERV_VMBUS_H +#define HW_HYPERV_VMBUS_H + +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" +#include "hw/qdev-core.h" +#include "migration/vmstate.h" +#include "hw/hyperv/vmbus-proto.h" +#include "qemu/uuid.h" + +#define TYPE_VMBUS_DEVICE "vmbus-dev" + +#define VMBUS_DEVICE(obj) \ + OBJECT_CHECK(VMBusDevice, (obj), TYPE_VMBUS_DEVICE) +#define VMBUS_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(VMBusDeviceClass, (klass), TYPE_VMBUS_DEVICE) +#define VMBUS_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VMBusDeviceClass, (obj), TYPE_VMBUS_DEVICE) + +/* + * Object wrapping a GPADL -- GPA Descriptor List -- an array of guest phy= sical + * pages, to be used for various buffers shared between the host and the g= uest. + */ +typedef struct VMBusGpadl VMBusGpadl; +/* + * VMBus channel -- a pair of ring buffers for either direction, placed wi= thin + * one GPADL, and the associated notification means. + */ +typedef struct VMBusChannel VMBusChannel; +/* + * Base class for VMBus devices. Includes one or more channels. Identifi= ed by + * class GUID and instance GUID. + */ +typedef struct VMBusDevice VMBusDevice; + +typedef void(*VMBusChannelNotifyCb)(struct VMBusChannel *chan); + +typedef struct VMBusDeviceClass { + DeviceClass parent; + + QemuUUID classid; + QemuUUID instanceid; /* Fixed UUID for singleton devices */ + uint16_t channel_flags; + uint16_t mmio_size_mb; + + /* Extentions to standard device callbacks */ + void (*vmdev_realize)(VMBusDevice *vdev, Error **errp); + void (*vmdev_unrealize)(VMBusDevice *vdev); + void (*vmdev_reset)(VMBusDevice *vdev); + /* + * Calculate the number of channels based on the device properties. C= alled + * at realize time. + **/ + uint16_t (*num_channels)(VMBusDevice *vdev); + /* + * Device-specific actions to complete the otherwise successful proces= s of + * opening a channel. + * Return 0 on success, -errno on failure. + */ + int (*open_channel)(VMBusChannel *chan); + /* + * Device-specific actions to perform before closing a channel. + */ + void (*close_channel)(VMBusChannel *chan); + /* + * Main device worker; invoked in response to notifications from either + * side, when there's work to do with the data in the channel ring buf= fers. + */ + VMBusChannelNotifyCb chan_notify_cb; +} VMBusDeviceClass; + +struct VMBusDevice { + DeviceState parent; + QemuUUID instanceid; + uint16_t num_channels; + VMBusChannel *channels; + AddressSpace *dma_as; +}; + +extern const VMStateDescription vmstate_vmbus_dev; + +/* + * A unit of work parsed out of a message in the receive (i.e. guest->host) + * ring buffer of a channel. It's supposed to be subclassed (through + * embedding) by the specific devices. + */ +typedef struct VMBusChanReq { + VMBusChannel *chan; + uint16_t pkt_type; + uint32_t msglen; + void *msg; + uint64_t transaction_id; + bool need_comp; + QEMUSGList sgl; +} VMBusChanReq; + +VMBusDevice *vmbus_channel_device(VMBusChannel *chan); +VMBusChannel *vmbus_device_channel(VMBusDevice *dev, uint32_t chan_idx); +uint32_t vmbus_channel_idx(VMBusChannel *chan); +bool vmbus_channel_is_open(VMBusChannel *chan); + +/* + * Notify (on guest's behalf) the host side of the channel that there's da= ta in + * the ringbuffer to process. + */ +void vmbus_channel_notify_host(VMBusChannel *chan); + +/* + * Reserve space for a packet in the send (i.e. host->guest) ringbuffer. = If + * there isn't enough room, indicate that to the guest, to be notified whe= n it + * becomes available. + * Return 0 on success, negative errno on failure. + * The ringbuffer indices are NOT updated, the requested space indicator m= ay. + */ +int vmbus_channel_reserve(VMBusChannel *chan, + uint32_t desclen, uint32_t msglen); + +/* + * Send a packet to the guest. The space for the packet MUST be reserved + * first. + * Return total number of bytes placed in the send ringbuffer on success, + * negative errno on failure. + * The ringbuffer indices are updated on success, and the guest is signale= d if + * needed. + */ +ssize_t vmbus_channel_send(VMBusChannel *chan, uint16_t pkt_type, + void *desc, uint32_t desclen, + void *msg, uint32_t msglen, + bool need_comp, uint64_t transaction_id); + +/* + * Prepare to fetch a batch of packets from the receive ring buffer. + * Return 0 on success, negative errno on failure. + */ +int vmbus_channel_recv_start(VMBusChannel *chan); + +/* + * Shortcut for a common case of sending a simple completion packet with no + * auxiliary descriptors. + */ +ssize_t vmbus_channel_send_completion(VMBusChanReq *req, + void *msg, uint32_t msglen); + +/* + * Peek at the receive (i.e. guest->host) ring buffer and extract a unit of + * work (a device-specific subclass of VMBusChanReq) from a packet if ther= e's + * one. + * Return an allocated buffer, containing the request of @size with filled + * VMBusChanReq at the beginning, followed by the message payload, or NULL= on + * failure. + * The ringbuffer indices are NOT updated, nor is the private copy of the = read + * index. + */ +void *vmbus_channel_recv_peek(VMBusChannel *chan, uint32_t size); + +/* + * Update the private copy of the read index once the preceding peek is de= emed + * successful. + * The ringbuffer indices are NOT updated. + */ +void vmbus_channel_recv_pop(VMBusChannel *chan); + +/* + * Propagate the private copy of the read index into the receive ring buff= er, + * and thus complete the reception of a series of packets. Notify guest if + * needed. + * Return the number of bytes popped off the receive ring buffer by the + * preceding recv_peek/recv_pop calls on success, negative errno on failur= e. + */ +ssize_t vmbus_channel_recv_done(VMBusChannel *chan); + +/* + * Free the request allocated by vmbus_channel_recv_peek, together with its + * fields. + */ +void vmbus_free_req(void *req); + +/* + * Find and reference a GPADL by @gpadl_id. + * If not found return NULL. + */ +VMBusGpadl *vmbus_get_gpadl(VMBusChannel *chan, uint32_t gpadl_id); + +/* + * Unreference @gpadl. If the reference count drops to zero, free it. + * @gpadl may be NULL, in which case nothing is done. + */ +void vmbus_put_gpadl(VMBusGpadl *gpadl); + +/* + * Calculate total length in bytes of @gpadl. + * @gpadl must be valid. + */ +uint32_t vmbus_gpadl_len(VMBusGpadl *gpadl); + +/* + * Copy data from @iov to @gpadl at offset @off. + * Return the number of bytes copied, or a negative status on failure. + */ +ssize_t vmbus_iov_to_gpadl(VMBusChannel *chan, VMBusGpadl *gpadl, uint32_t= off, + const struct iovec *iov, size_t iov_cnt); + +/* + * Map SGList contained in the request @req, at offset @off and no more th= an + * @len bytes, for io in direction @dir, and populate @iov with the mapped + * iovecs. + * Return the number of iovecs mapped, or negative status on failure. + */ +int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *iov, + unsigned iov_cnt, size_t len, size_t off); + +/* + * Unmap *iov mapped with vmbus_map_sgl, marking the number of bytes @acce= ssed. + */ +void vmbus_unmap_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *io= v, + unsigned iov_cnt, size_t accessed); + +#endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905143; cv=none; d=zohomail.com; s=zohoarc; b=RifZvzt+pKEyapxXKlk1XLytrtzFdaqfrR5e9DNGtG649wjZCYWQiGqMJWC/lELGXphpmEaBRA2zWWEUEQjxVsTba2qhZ2VGdKrsda3c20NAqEgKiD7T8NzU4bGT1a/KIfEDK71EivUMIZjOowjvgVZEAABHb0BWXcunFuLgmTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905143; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7pmo1gzm6+qo4HgHXayCD2klZJJl9+0dR75F+/rudz0=; b=Hxai1pUTdwErHdl12kGyZ/Bpc+H4ivwXEiCReU4VpLKfH2zfBD3JgSqLWAufJWetyxuea4gTJv+YO03OY/9wGR/GtKwQR8Ufx5w043Rn4BL3J+CSeIhpmTp0JCqUKXVBY/C20b1o/f8nwcxf8iWjrdZmPk7TkljfYsmOhijmuTU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905143986135.55180132390205; Thu, 11 Jun 2020 12:52:23 -0700 (PDT) Received: from localhost ([::1]:39688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTFO-000166-Kx for importer@patchew.org; Thu, 11 Jun 2020 15:52:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8c-0007bh-4l for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60332 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8Y-0000uY-Ln for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-ja6ykj-HONeHon8OqPoymg-1; Thu, 11 Jun 2020 15:45:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C42419057A8; Thu, 11 Jun 2020 19:45:11 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36AC85D9DC; Thu, 11 Jun 2020 19:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904717; 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=7pmo1gzm6+qo4HgHXayCD2klZJJl9+0dR75F+/rudz0=; b=GR9Mc4nkzJxpIIItFqjp0cQ/RJHSldUmjplxPkRI3aQYoojNPFkgMZ4O7Uq1YLE1gNTbXM TshKsqXLaVcl+Lao1sEx+e/wERKVknaytR1L7bwTzs4U53bjxEZEdCOGRBMRxfMSfM3/Or HEVFXVYwbZolUw8DPFALR59Oz5bzHRg= X-MC-Unique: ja6ykj-HONeHon8OqPoymg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 020/115] i386:pc: whitelist dynamic vmbus-bridge Date: Thu, 11 Jun 2020 15:43:14 -0400 Message-Id: <20200611194449.31468-21-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Maciej S . Szmigiero" , Jon Doron , Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jon Doron As vmbus-bridge is derived from sysbus device, it has to be whitelisted to be allowed to be created with -device. Signed-off-by: Roman Kagan Signed-off-by: Maciej S. Szmigiero Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-5-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index f66e1d73ce..2613d25bda 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -60,6 +60,7 @@ #include "migration/global_state.h" #include "migration/misc.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h" =20 @@ -419,6 +420,7 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; m->default_display =3D "std"; machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); } =20 static void pc_i440fx_5_1_machine_options(MachineClass *m) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 4ba8ac8774..688d57ddf3 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -53,6 +53,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h" =20 @@ -348,6 +349,7 @@ static void pc_q35_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); m->max_cpus =3D 288; } =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905155; cv=none; d=zohomail.com; s=zohoarc; b=Fnkjb45rYi6USzd2LxpgfYKY/tP9c/4uQnIYMI3vRhi70fRDWuLsxefyT+tLtAf493oQmthsS/Wjj+pfMhLiRDWGYStd60sTDOZbi30YRMHdPTjy2XbHE6qznIeNU013Vcxn5/Jm33OY+uOghNVWOduRiiVExwknaD/xuiH5TZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905155; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LPRP0T2sFGdHAybki/yJMFxzlZOXyMdUgi3st+kiiPg=; b=DAY/90X3y13infxSoiZRGZhl4wBxIcHDB7vm5O2MHvbYqShUJqABwLwEipHg3liCSFO3ePGMHhw9f7Hlu+K8BVY5ruQZYavHdFa5j47BJn0srBugFqHHv2dl2nPBbW6tY1joafT7+/gzmQTIhnXN4W3/vqZy/2JxlPBp4W38nTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905155443350.8221449172522; Thu, 11 Jun 2020 12:52:35 -0700 (PDT) Received: from localhost ([::1]:40086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTFZ-0001JM-FV for importer@patchew.org; Thu, 11 Jun 2020 15:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8Z-0007Z9-3y for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:20 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49441 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8W-0000tE-NJ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-Fk_QktUKPhiUNDbYzZCJZA-1; Thu, 11 Jun 2020 15:45:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B771461; Thu, 11 Jun 2020 19:45:12 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B92F55D9DC; Thu, 11 Jun 2020 19:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904715; 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=LPRP0T2sFGdHAybki/yJMFxzlZOXyMdUgi3st+kiiPg=; b=GBr9w0BNbi1W1T9TpljU9AnAdr/GTvLZsSdtu00RkUCCPMOnYWg6CrAPUJcM17aqbrLuHH OJq5gmRWFA3fmrgOyWkJ56tl0bwTs8NztAMMyZTZR6oFPWvaexlhfjyF5n2HXiLgRmELtQ 0eo3vC6G3y3vk47lM1Ln35NEXhkeypY= X-MC-Unique: Fk_QktUKPhiUNDbYzZCJZA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 021/115] i386: Hyper-V VMBus ACPI DSDT entry Date: Thu, 11 Jun 2020 15:43:15 -0400 Message-Id: <20200611194449.31468-22-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Maciej S . Szmigiero" , Evgeny Yakovlev , Jon Doron , Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jon Doron Guest OS uses ACPI to discover VMBus presence. Add a corresponding entry to DSDT in case VMBus has been enabled. Experimentally Windows guests were found to require this entry to include two IRQ resources. They seem to never be used but they still have to be there. Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default. Signed-off-by: Evgeny Yakovlev Signed-off-by: Roman Kagan Signed-off-by: Maciej S. Szmigiero Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-6-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+) diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index 802bbc8c96..2acb2185e8 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge= =3D { }, }; =20 +static Property vmbus_bridge_props[] =3D { + DEFINE_PROP_UINT8("irq0", VMBusBridge, irq0, 7), + DEFINE_PROP_UINT8("irq1", VMBusBridge, irq1, 13), + DEFINE_PROP_END_OF_LIST() +}; + static void vmbus_bridge_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); @@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klas= s, void *data) sk->explicit_ofw_unit_address =3D vmbus_bridge_ofw_unit_address; set_bit(DEVICE_CATEGORY_BRIDGE, k->categories); k->vmsd =3D &vmstate_vmbus_bridge; + device_class_set_props(k, vmbus_bridge_props); /* override SysBusDevice's default */ k->user_creatable =3D true; } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2e15f6848e..dcdfbd8906 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -50,6 +50,7 @@ #include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "hw/hyperv/vmbus-bridge.h" =20 /* Supported chipsets: */ #include "hw/southbridge/piix.h" @@ -1270,9 +1271,47 @@ static Aml *build_com_device_aml(uint8_t uid) return dev; } =20 +static Aml *build_vmbus_device_aml(VMBusBridge *vmbus_bridge) +{ + Aml *dev; + Aml *method; + Aml *crs; + + dev =3D aml_device("VMBS"); + aml_append(dev, aml_name_decl("STA", aml_int(0xF))); + aml_append(dev, aml_name_decl("_HID", aml_string("VMBus"))); + aml_append(dev, aml_name_decl("_UID", aml_int(0x0))); + aml_append(dev, aml_name_decl("_DDN", aml_string("VMBUS"))); + + method =3D aml_method("_DIS", 0, AML_NOTSERIALIZED); + aml_append(method, aml_store(aml_and(aml_name("STA"), aml_int(0xD), NU= LL), + aml_name("STA"))); + aml_append(dev, method); + + method =3D aml_method("_PS0", 0, AML_NOTSERIALIZED); + aml_append(method, aml_store(aml_or(aml_name("STA"), aml_int(0xF), NUL= L), + aml_name("STA"))); + aml_append(dev, method); + + method =3D aml_method("_STA", 0, AML_NOTSERIALIZED); + aml_append(method, aml_return(aml_name("STA"))); + aml_append(dev, method); + + aml_append(dev, aml_name_decl("_PS3", aml_int(0x0))); + + crs =3D aml_resource_template(); + aml_append(crs, aml_irq_no_flags(vmbus_bridge->irq0)); + /* FIXME: newer HyperV gets by with only one IRQ */ + aml_append(crs, aml_irq_no_flags(vmbus_bridge->irq1)); + aml_append(dev, aml_name_decl("_CRS", crs)); + + return dev; +} + static void build_isa_devices_aml(Aml *table) { ISADevice *fdc =3D pc_find_fdc0(); + VMBusBridge *vmbus_bridge =3D vmbus_bridge_find(); bool ambiguous; =20 Aml *scope =3D aml_scope("_SB.PCI0.ISA"); @@ -1297,6 +1336,10 @@ static void build_isa_devices_aml(Aml *table) isa_build_aml(ISA_BUS(obj), scope); } =20 + if (vmbus_bridge) { + aml_append(scope, build_vmbus_device_aml(vmbus_bridge)); + } + aml_append(table, scope); } =20 diff --git a/include/hw/hyperv/vmbus-bridge.h b/include/hw/hyperv/vmbus-bri= dge.h index 9cc8f780de..c0a06d832c 100644 --- a/include/hw/hyperv/vmbus-bridge.h +++ b/include/hw/hyperv/vmbus-bridge.h @@ -19,6 +19,9 @@ typedef struct VMBus VMBus; typedef struct VMBusBridge { SysBusDevice parent_obj; =20 + uint8_t irq0; + uint8_t irq1; + VMBus *bus; } VMBusBridge; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907790; cv=none; d=zohomail.com; s=zohoarc; b=YSQA114150zflPzYJq5yynWTRllKYrcvuF59pY/Z3mArn79qCBswLFNRF1KkOmlshVWjhAB/3UpM2wMpbyd8RpxQNL4pwpwK+4I9A0pa+fu6ifCRhwZNksJkAsfM76Um66Zi5u0BZviFuryfic2Cn3b6Vn2S1XfJ+TWJ62mz7PA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907790; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YA/PmyaJ3w1Dt/TGbyfek3qVmaDq/4S8uhvGmNOuqGM=; b=DzmuXDeYI05uvGKclEMHp1TzPjkvQ0Umn6/8VXIJJt0POARgJVBwU5dPyDK4YyogXKjXEjzysONoxnTq4JvMX36cFYLGMPBZxawx+i2OgsGE6LSFvdg0J2CfazNayBpzXvyikl5PwP6OEDlMhb6P9MZB+9PM8ztbVMBuJeJ2K0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907790964792.3222384834033; Thu, 11 Jun 2020 13:36:30 -0700 (PDT) Received: from localhost ([::1]:49690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTw5-0006aG-KP for importer@patchew.org; Thu, 11 Jun 2020 16:36:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9k-0000XO-2u for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49458 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9g-0001Ig-Up for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-vw8oNuxRPtyW18Yff_VmuA-1; Thu, 11 Jun 2020 15:45:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF07F8015CE; Thu, 11 Jun 2020 19:45:12 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58BE55D9DC; Thu, 11 Jun 2020 19:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904788; 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=YA/PmyaJ3w1Dt/TGbyfek3qVmaDq/4S8uhvGmNOuqGM=; b=hsx4jErXMhYQlzt2BRoNcw3G/ss/Yn8mvKE70sEifUVJPOtrn1Y4W4IaH9L/Ug2yjlyRlq krWoddDoYNbofXNchqPBaWtJAffWN33pGdrXJSGcPgU6DG8Q8hUrUd5DlVcp9Y4lY+p4ci 9KLht2C5bpQ5mtbDqYGRPs83MgQHSlY= X-MC-Unique: vw8oNuxRPtyW18Yff_VmuA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 022/115] vmbus: add infrastructure to save/load vmbus requests Date: Thu, 11 Jun 2020 15:43:16 -0400 Message-Id: <20200611194449.31468-23-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Maciej S . Szmigiero" , Jon Doron , Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jon Doron This can be allow to include controller-specific data while saving/loading in-flight scsi requests of the vmbus scsi controller. Signed-off-by: Roman Kagan Signed-off-by: Maciej S. Szmigiero Signed-off-by: Jon Doron Message-Id: <20200424123444.3481728-7-arilou@gmail.com> Signed-off-by: Paolo Bonzini --- hw/hyperv/vmbus.c | 99 +++++++++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus.h | 3 ++ 2 files changed, 102 insertions(+) diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index 2acb2185e8..f371240176 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -1272,6 +1272,105 @@ void vmbus_free_req(void *req) g_free(req); } =20 +static const VMStateDescription vmstate_sgent =3D { + .name =3D "vmbus/sgentry", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(base, ScatterGatherEntry), + VMSTATE_UINT64(len, ScatterGatherEntry), + VMSTATE_END_OF_LIST() + } +}; + +typedef struct VMBusChanReqSave { + uint16_t chan_idx; + uint16_t pkt_type; + uint32_t msglen; + void *msg; + uint64_t transaction_id; + bool need_comp; + uint32_t num; + ScatterGatherEntry *sgl; +} VMBusChanReqSave; + +static const VMStateDescription vmstate_vmbus_chan_req =3D { + .name =3D "vmbus/vmbus_chan_req", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(chan_idx, VMBusChanReqSave), + VMSTATE_UINT16(pkt_type, VMBusChanReqSave), + VMSTATE_UINT32(msglen, VMBusChanReqSave), + VMSTATE_VBUFFER_ALLOC_UINT32(msg, VMBusChanReqSave, 0, NULL, msgle= n), + VMSTATE_UINT64(transaction_id, VMBusChanReqSave), + VMSTATE_BOOL(need_comp, VMBusChanReqSave), + VMSTATE_UINT32(num, VMBusChanReqSave), + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(sgl, VMBusChanReqSave, num, + vmstate_sgent, ScatterGatherE= ntry), + VMSTATE_END_OF_LIST() + } +}; + +void vmbus_save_req(QEMUFile *f, VMBusChanReq *req) +{ + VMBusChanReqSave req_save; + + req_save.chan_idx =3D req->chan->subchan_idx; + req_save.pkt_type =3D req->pkt_type; + req_save.msglen =3D req->msglen; + req_save.msg =3D req->msg; + req_save.transaction_id =3D req->transaction_id; + req_save.need_comp =3D req->need_comp; + req_save.num =3D req->sgl.nsg; + req_save.sgl =3D g_memdup(req->sgl.sg, + req_save.num * sizeof(ScatterGatherEntry)); + + vmstate_save_state(f, &vmstate_vmbus_chan_req, &req_save, NULL); + + g_free(req_save.sgl); +} + +void *vmbus_load_req(QEMUFile *f, VMBusDevice *dev, uint32_t size) +{ + VMBusChanReqSave req_save; + VMBusChanReq *req =3D NULL; + VMBusChannel *chan =3D NULL; + uint32_t i; + + vmstate_load_state(f, &vmstate_vmbus_chan_req, &req_save, 0); + + if (req_save.chan_idx >=3D dev->num_channels) { + error_report("%s: %u(chan_idx) > %u(num_channels)", __func__, + req_save.chan_idx, dev->num_channels); + goto out; + } + chan =3D &dev->channels[req_save.chan_idx]; + + if (vmbus_channel_reserve(chan, 0, req_save.msglen)) { + goto out; + } + + req =3D vmbus_alloc_req(chan, size, req_save.pkt_type, req_save.msglen, + req_save.transaction_id, req_save.need_comp); + if (req_save.msglen) { + memcpy(req->msg, req_save.msg, req_save.msglen); + } + + for (i =3D 0; i < req_save.num; i++) { + qemu_sglist_add(&req->sgl, req_save.sgl[i].base, req_save.sgl[i].l= en); + } + +out: + if (req_save.msglen) { + g_free(req_save.msg); + } + if (req_save.num) { + g_free(req_save.sgl); + } + return req; +} + static void channel_event_cb(EventNotifier *e) { VMBusChannel *chan =3D container_of(e, VMBusChannel, notifier); diff --git a/include/hw/hyperv/vmbus.h b/include/hw/hyperv/vmbus.h index 99b647e1d6..40e8417eec 100644 --- a/include/hw/hyperv/vmbus.h +++ b/include/hw/hyperv/vmbus.h @@ -224,4 +224,7 @@ int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, = struct iovec *iov, void vmbus_unmap_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *io= v, unsigned iov_cnt, size_t accessed); =20 +void vmbus_save_req(QEMUFile *f, VMBusChanReq *req); +void *vmbus_load_req(QEMUFile *f, VMBusDevice *dev, uint32_t size); + #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905455; cv=none; d=zohomail.com; s=zohoarc; b=n2YOxOP6SfBDTaKVkiRw47SGITFwO55owgV3pXKTTA634zvjqJUEwB6daAmZFTQglaBOnDaOMb3bRwAGH2gF29gCoH75AFvHlCKwsLKHLSX/hUegekxhUW92H9lIk9pyLgem1LV/iYi2WFnZLaeY9Ud9t16CInL/mr5xYzSZkBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905455; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ocL89FGGKbmVMoIaKKI8IoyvSt8Z4cxyeOb9yEuX8ow=; b=CCc0KnxsVNBfAP8fZgm0IEg86nKm5giUK5L6pqSKPQ2SFOHKXnbx+MP/uaLIOhw8T3QuGKjtJuq9pVjwQ9VJGd6UKB1Q8/65HFjOk/F07HLu24szSJcv8MZJmz4zYh88yLagzMldr9KKsFV5O8dai1wm55QqbCIOsnZvTuidTaE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190545561364.42466484906572; Thu, 11 Jun 2020 12:57:35 -0700 (PDT) Received: from localhost ([::1]:56626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTKQ-0001U9-Bl for importer@patchew.org; Thu, 11 Jun 2020 15:57:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8d-0007cp-LQ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:24 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37962 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8Y-0000uV-MB for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-WfwU4piBMyS9FxFlhZd1ow-1; Thu, 11 Jun 2020 15:45:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58E3A107ACCA; Thu, 11 Jun 2020 19:45:13 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBB415D9DC; Thu, 11 Jun 2020 19:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904717; 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=ocL89FGGKbmVMoIaKKI8IoyvSt8Z4cxyeOb9yEuX8ow=; b=GCNapBG2KFBYVrJH5aju2IijJ16FPpk835e9yeITFb4KB0qmWTOwPvGKSx/r7n/4vrnOSR GAsqfbJTbXtbUZ2QPoR+0pnwQLSovwh/1MYzeBmp1gfjt2PatW0AVtZHajbVxmbfPDhB9m 22Lu595YdzNIfw9v2MtQVmWVa9OMXEc= X-MC-Unique: WfwU4piBMyS9FxFlhZd1ow-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 023/115] target/i386: Fix the CPUID leaf CPUID_Fn80000008 Date: Thu, 11 Jun 2020 15:43:17 -0400 Message-Id: <20200611194449.31468-24-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Babu Moger , Philipp Eppelt <1871842@bugs.launchpad.net> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Babu Moger CPUID leaf CPUID_Fn80000008_ECX provides information about the number of threads supported by the processor. It was found that the field ApicIdSize(bits 15-12) was not set correctly. ApicIdSize is defined as the number of bits required to represent all the ApicId values within a package. Valid Values: Value Description 3h-0h Reserved. 4h up to 16 threads. 5h up to 32 threads. 6h up to 64 threads. 7h up to 128 threads. Fh-8h Reserved. Fix the bit appropriately. This came up during following thread. https://lore.kernel.org/qemu-devel/158643709116.17430.15995069125716778943.= malonedeb@wampee.canonical.com/#t Refer the Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors. The documentation is available from the bugzilla Link below. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Reported-by: Philipp Eppelt <1871842@bugs.launchpad.net> Signed-off-by: Babu Moger Message-Id: <20200417215345.64800.73351.stgit@localhost.localdomain> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ba05da3f2e..25a8f6b1ad 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5837,11 +5837,20 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, *eax =3D cpu->phys_bits; } *ebx =3D env->features[FEAT_8000_0008_EBX]; - *ecx =3D 0; - *edx =3D 0; if (cs->nr_cores * cs->nr_threads > 1) { - *ecx |=3D (cs->nr_cores * cs->nr_threads) - 1; + /* + * Bits 15:12 is "The number of bits in the initial + * Core::X86::Apic::ApicId[ApicId] value that indicate + * thread ID within a package". This is already stored at + * CPUX86State::pkg_offset. + * Bits 7:0 is "The number of threads in the package is NC+1" + */ + *ecx =3D (env->pkg_offset << 12) | + ((cs->nr_cores * cs->nr_threads) - 1); + } else { + *ecx =3D 0; } + *edx =3D 0; break; case 0x8000000A: if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906308; cv=none; d=zohomail.com; s=zohoarc; b=Yb7eRlHQgZ+q1i03xvhwIuphqLTooSKCeenz2jounw9G4W0dXwMvbGhhRCTsCXZdVZAHyWHc+bmTIka4/qHp9U0HAwMrJIwD0I0BHfSFSsmOsvJIhYIbl1w9isqWVTutbx1x55+ZL2nDsHx0TTkY+bffGEWDdHv3HRFx5iSmknk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906308; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MrdrRYejp3x0pPisYrmqtFlKLM7DEQL3Jy2KygyfTlI=; b=JqnDVMYWBqEm+9Uxzg/xwlk848gIGl8tKm5dAdz6Vs/V1Hcd8OehApeVitFV5kQROeZqZ4s+AVHYA1u5uxKwoVeNsUf6XNWwrq80X9HnIIxV9ImUAOq6K+ORv+yTV1rXUW2yUltdF28ASqd+GAe5GKUQ1N3U8J1AECmJBdt8sHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906308390569.3959425139278; Thu, 11 Jun 2020 13:11:48 -0700 (PDT) Received: from localhost ([::1]:43562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTY7-0005Wn-5P for importer@patchew.org; Thu, 11 Jun 2020 16:11:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9W-00004r-Jh for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:18 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33327 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9U-0001Ev-Jm for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-bme4Yv0vP8u6ImnceFK0ow-1; Thu, 11 Jun 2020 15:45:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E5A85107ACF4; Thu, 11 Jun 2020 19:45:13 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7652C5D9DC; Thu, 11 Jun 2020 19:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904775; 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=MrdrRYejp3x0pPisYrmqtFlKLM7DEQL3Jy2KygyfTlI=; b=Wbbd+JKjqNxKhM93aYMZBdCx8KqWb2DVhvoQhjsqXxJbIG+Wxcm35E+/yGpd2HPd++ZBg6 o3m7bNv5ngF2bW4TW6cjdmWuWwdCjxBapgDS0GvGrjsXM9pSoOjfSNzZJF5BPnmU/7dZUC LvAHy3zp0XmadAPLkC9PlwO9NeIIR0Q= X-MC-Unique: bme4Yv0vP8u6ImnceFK0ow-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 024/115] target/i386: fix phadd* with identical destination and source register Date: Thu, 11 Jun 2020 15:43:18 -0400 Message-Id: <20200611194449.31468-25-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Janne Grunau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Janne Grunau Detected by asm test suite failures in dav1d (https://code.videolan.org/videolan/dav1d). Can be reproduced by `qemu-x86_64 -cpu core2duo ./tests/checkasm --test=3Dmc_8bpc 1659890620`. Signed-off-by: Janne Grunau Message-Id: <20200401225253.30745-1-j@jannau.net> Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/ops_sse.h | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 4658768de2..01d6017412 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -1435,34 +1435,47 @@ void glue(helper_pshufb, SUFFIX)(CPUX86State *env, = Reg *d, Reg *s) =20 void glue(helper_phaddw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->W(0) =3D (int16_t)d->W(0) + (int16_t)d->W(1); - d->W(1) =3D (int16_t)d->W(2) + (int16_t)d->W(3); - XMM_ONLY(d->W(2) =3D (int16_t)d->W(4) + (int16_t)d->W(5)); - XMM_ONLY(d->W(3) =3D (int16_t)d->W(6) + (int16_t)d->W(7)); - d->W((2 << SHIFT) + 0) =3D (int16_t)s->W(0) + (int16_t)s->W(1); - d->W((2 << SHIFT) + 1) =3D (int16_t)s->W(2) + (int16_t)s->W(3); - XMM_ONLY(d->W(6) =3D (int16_t)s->W(4) + (int16_t)s->W(5)); - XMM_ONLY(d->W(7) =3D (int16_t)s->W(6) + (int16_t)s->W(7)); + + Reg r; + + r.W(0) =3D (int16_t)d->W(0) + (int16_t)d->W(1); + r.W(1) =3D (int16_t)d->W(2) + (int16_t)d->W(3); + XMM_ONLY(r.W(2) =3D (int16_t)d->W(4) + (int16_t)d->W(5)); + XMM_ONLY(r.W(3) =3D (int16_t)d->W(6) + (int16_t)d->W(7)); + r.W((2 << SHIFT) + 0) =3D (int16_t)s->W(0) + (int16_t)s->W(1); + r.W((2 << SHIFT) + 1) =3D (int16_t)s->W(2) + (int16_t)s->W(3); + XMM_ONLY(r.W(6) =3D (int16_t)s->W(4) + (int16_t)s->W(5)); + XMM_ONLY(r.W(7) =3D (int16_t)s->W(6) + (int16_t)s->W(7)); + + *d =3D r; } =20 void glue(helper_phaddd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->L(0) =3D (int32_t)d->L(0) + (int32_t)d->L(1); - XMM_ONLY(d->L(1) =3D (int32_t)d->L(2) + (int32_t)d->L(3)); - d->L((1 << SHIFT) + 0) =3D (int32_t)s->L(0) + (int32_t)s->L(1); - XMM_ONLY(d->L(3) =3D (int32_t)s->L(2) + (int32_t)s->L(3)); + Reg r; + + r.L(0) =3D (int32_t)d->L(0) + (int32_t)d->L(1); + XMM_ONLY(r.L(1) =3D (int32_t)d->L(2) + (int32_t)d->L(3)); + r.L((1 << SHIFT) + 0) =3D (int32_t)s->L(0) + (int32_t)s->L(1); + XMM_ONLY(r.L(3) =3D (int32_t)s->L(2) + (int32_t)s->L(3)); + + *d =3D r; } =20 void glue(helper_phaddsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - d->W(0) =3D satsw((int16_t)d->W(0) + (int16_t)d->W(1)); - d->W(1) =3D satsw((int16_t)d->W(2) + (int16_t)d->W(3)); - XMM_ONLY(d->W(2) =3D satsw((int16_t)d->W(4) + (int16_t)d->W(5))); - XMM_ONLY(d->W(3) =3D satsw((int16_t)d->W(6) + (int16_t)d->W(7))); - d->W((2 << SHIFT) + 0) =3D satsw((int16_t)s->W(0) + (int16_t)s->W(1)); - d->W((2 << SHIFT) + 1) =3D satsw((int16_t)s->W(2) + (int16_t)s->W(3)); - XMM_ONLY(d->W(6) =3D satsw((int16_t)s->W(4) + (int16_t)s->W(5))); - XMM_ONLY(d->W(7) =3D satsw((int16_t)s->W(6) + (int16_t)s->W(7))); + Reg r; + + r.W(0) =3D satsw((int16_t)d->W(0) + (int16_t)d->W(1)); + r.W(1) =3D satsw((int16_t)d->W(2) + (int16_t)d->W(3)); + XMM_ONLY(r.W(2) =3D satsw((int16_t)d->W(4) + (int16_t)d->W(5))); + XMM_ONLY(r.W(3) =3D satsw((int16_t)d->W(6) + (int16_t)d->W(7))); + r.W((2 << SHIFT) + 0) =3D satsw((int16_t)s->W(0) + (int16_t)s->W(1)); + r.W((2 << SHIFT) + 1) =3D satsw((int16_t)s->W(2) + (int16_t)s->W(3)); + XMM_ONLY(r.W(6) =3D satsw((int16_t)s->W(4) + (int16_t)s->W(5))); + XMM_ONLY(r.W(7) =3D satsw((int16_t)s->W(6) + (int16_t)s->W(7))); + + *d =3D r; } =20 void glue(helper_pmaddubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906656; cv=none; d=zohomail.com; s=zohoarc; b=evbRFRKlReHglfSRLG1fezEWy9eule092nzj++T3RmoVI89ya2d9663ug1TWzq9m5SMviO50+GgzN9VHsQQ2KHuUomAkkB+Bc/DVv14vjYDUeNECOe+asSVU5CaopzDHz4IOVyH0AROEf4LWK8g+hXW2dfE2eoCBm9VCWIxvUzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906656; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0vcYVmHN6298y0pk5Vv1nPDyUwWH4XD/eWqdeOMQvvI=; b=cxsQtJOfViwcqU0mNKCuiTQ1U+DmdHhs5PDLSvegA2yOUbkWBhADOvzGhz/CEJf4CAZ9LCgoTWRwPu6z/RgSRgAoiJLUSoAfeWMsYukUni+4l22EIgcmc3DwdcTuaYKu/tHU8DpbWpV1XmnvXkxEavvmQbglGv2JQbonU+ENcPM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906656559340.47149475229764; Thu, 11 Jun 2020 13:17:36 -0700 (PDT) Received: from localhost ([::1]:39612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTdn-0008UW-1z for importer@patchew.org; Thu, 11 Jun 2020 16:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8z-00080Y-93 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:45 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42466 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8w-00015p-Av for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-TN9sdEvTNySs2WjD68OE-Q-1; Thu, 11 Jun 2020 15:45:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53B8B19057A0; Thu, 11 Jun 2020 19:45:14 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ECBD5D9DC; Thu, 11 Jun 2020 19:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904741; 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=0vcYVmHN6298y0pk5Vv1nPDyUwWH4XD/eWqdeOMQvvI=; b=UMv1FgcByLfVZbytZE8rBIhCFs1NuTq+27bcpv0cFyxXxVI5b06DsdJZmn3eBy6KHR5sWC 2KI3h62sT6BwwvSMPaszURhJh+wLKB9PCQ6UtXccOsIStI2ZFhv3UIIIKJn43mnnIDVOte 0rGxEgRRW86w/XgDBxcpyNN86Sndxyk= X-MC-Unique: TN9sdEvTNySs2WjD68OE-Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 025/115] hw/i386/vmport: Add reference to VMware open-vm-tools Date: Thu, 11 Jun 2020 15:43:19 -0400 Message-Id: <20200611194449.31468-26-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon This official VMware open-source project can be used as reference to understand how guest code interacts with VMPort virtual device. Thus, providing understanding on how device is expected to behave. Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-2-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 1aaaab691a..fc0074608e 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -21,6 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN * THE SOFTWARE. */ + +/* + * Guest code that interacts with this virtual device can be found + * in VMware open-vm-tools open-source project: + * https://github.com/vmware/open-vm-tools + */ + #include "qemu/osdep.h" #include "hw/isa/isa.h" #include "sysemu/hw_accel.h" --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905874; cv=none; d=zohomail.com; s=zohoarc; b=LtgZ6NXUg4+5KwukkuwS3p8qIYwtRCw8OTmeUbuaNlgGehJRvcvLhQrK+P/4Qsuss5Q9ghwqazlS8IgU7uu3AbVtbsza040dQiWY5lVaCMGyntZ8P0JBnDoc8VAdh/19VpzgJb5jkI3/5SzHdlP3bVec52iBFAoBEPz3bNnI4aE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905874; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Vl9+4Ve7uqE2qdXwMEU88RpILo1l/1GNFgId+2u59oQ=; b=bt1kp2+yi04WrspJyvkLyH3ngL8K78z/XWfdZVBWoU6ShXDiFV1z/1BRy5ithZ6CScomy+Wb3eafzEvlrr13hQddpU5BvjvsdOfbwH64zOg+wUW3iQq5DLeY6oW4iq6B8e9Nxhv+d2BS7U0oYETswDQ/xodzPUrRqpQlbTCOI+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905874973356.4476080847329; Thu, 11 Jun 2020 13:04:34 -0700 (PDT) Received: from localhost ([::1]:45848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTRA-0001Nk-JP for importer@patchew.org; Thu, 11 Jun 2020 16:04:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8t-0007t0-9z for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:39 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57705 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8r-00011Y-0A for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-8A9stek-P3W2dtLqGztl8A-1; Thu, 11 Jun 2020 15:45:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7E1E86ABD5; Thu, 11 Jun 2020 19:45:14 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 713D65D9DC; Thu, 11 Jun 2020 19:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904735; 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=Vl9+4Ve7uqE2qdXwMEU88RpILo1l/1GNFgId+2u59oQ=; b=dHPXwr0Z5c1XBPRZLep+fM70MlfGEEBjfVyVxo41LiTdakcsEOfDy9C6oxxKQBLHOM/LcT M7/2wocw0pqGRVDk+jufo2gPOGa6/xC65L1BDMCMtZef/KZG+FL3C4ZLcc8yah4Bge6c59 V2IHxLtXlmtBBFLjUKldbaG0EkDu8Zg= X-MC-Unique: 8A9stek-P3W2dtLqGztl8A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 026/115] hw/i386/vmport: Add device properties Date: Thu, 11 Jun 2020 15:43:20 -0400 Message-Id: <20200611194449.31468-27-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Liran Alon No functional change. This is done as a preparation for the following patches that will introduce several device properties. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200312165431.82118-3-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index fc0074608e..5985167dcf 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -30,6 +30,7 @@ =20 #include "qemu/osdep.h" #include "hw/isa/isa.h" +#include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "vmport.h" @@ -140,6 +141,10 @@ static void vmport_realizefn(DeviceState *dev, Error *= *errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); } =20 +static Property vmport_properties[] =3D { + DEFINE_PROP_END_OF_LIST(), +}; + static void vmport_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -147,6 +152,7 @@ static void vmport_class_initfn(ObjectClass *klass, voi= d *data) dc->realize =3D vmport_realizefn; /* Reason: realize sets global port_state */ dc->user_creatable =3D false; + device_class_set_props(dc, vmport_properties); } =20 static const TypeInfo vmport_info =3D { --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905330; cv=none; d=zohomail.com; s=zohoarc; b=eDrLmZojGt6zgQeyFSl9M4Z29UOUOimJBKS8YnbFoQPajvyxGW2z++PIUW1kPjDfLN+n/eXEbf6MDa/6bIm+VUazPhvdPtvVmRHtNCpg8Syr512foSYedHC/CAWxbhTOYC51mxqjsU2n+PBUXTVmNgK3X9yrNQQG6nYA5rQXxqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905330; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bNn3Gkj8eEfhoQRSqPAZgsCZ/OMlwZDfPyXZbMYK4G8=; b=NAJO+T24K0B7inx0SQpwRqi0gxyq8OKqkKJsNoUDuRLx9w4qnO+XBorpTPzIqkA0Pk46LjpS9Dc4gYFU9wW4fJPsDoeCAJWu2zfdVzCN0vCi5NGQqCOtZMGI5y2DigdSuJXdYJrUQLESf1HdgpEY0namUJpUF0P5u/g6XKOKv54= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905330174642.2756809834086; Thu, 11 Jun 2020 12:55:30 -0700 (PDT) Received: from localhost ([::1]:48546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTIO-0005ap-5E for importer@patchew.org; Thu, 11 Jun 2020 15:55:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8f-0007eF-20 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20953 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8a-0000vi-66 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-fetYdvshP5yMK4nIpBvCuw-1; Thu, 11 Jun 2020 15:45:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5604D1800D41; Thu, 11 Jun 2020 19:45:15 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 009515D9DC; Thu, 11 Jun 2020 19:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904718; 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=bNn3Gkj8eEfhoQRSqPAZgsCZ/OMlwZDfPyXZbMYK4G8=; b=ekvPw2f1JJti0PANIW1nPLl8K0sPvfrPexC0U7pyyrr9MM0Zd2WKOVrna0XHFkZ1nsoCva VqhLpcJCPlcVMF85WZtUE8c1xIj5aH+Cm+bfcBV1nh1HnskY4pl7STb/HXDhO4aW5dzUJ0 nTx528PGzuc/gfzmyr0Liaicyd0leOU= X-MC-Unique: fetYdvshP5yMK4nIpBvCuw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register Date: Thu, 11 Jun 2020 15:43:21 -0400 Message-Id: <20200611194449.31468-28-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon vmport_ioport_read() returns the value that should propagate to vCPU EAX register when guest reads VMPort IOPort (i.e. By x86 IN instruction). However, because vmport_ioport_read() calls cpu_synchronize_state(), the returned value gets overridden by the value in QEMU vCPU EAX register. i.e. cpu->env.regs[R_EAX]. To fix this issue, change vmport_ioport_read() to explicitly override cpu->env.regs[R_EAX] with the value it wish to propagate to vCPU EAX register. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-4-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + hw/i386/vmport.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index bb3a7b18b1..83f0fe5c91 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -43,6 +43,7 @@ GlobalProperty hw_compat_4_2[] =3D { { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, + { "vmport", "x-read-set-eax", "off" }, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 5985167dcf..3bb420a245 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -43,6 +43,11 @@ #define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 =20 +/* Compatibility flags for migration */ +#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 +#define VMPORT_COMPAT_READ_SET_EAX \ + (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) + #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 typedef struct VMPortState { @@ -51,6 +56,8 @@ typedef struct VMPortState { MemoryRegion io; VMPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; + + uint32_t compat_flags; } VMPortState; =20 static VMPortState *port_state; @@ -80,17 +87,33 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, =20 eax =3D env->regs[R_EAX]; if (eax !=3D VMPORT_MAGIC) { - return eax; + goto out; } =20 command =3D env->regs[R_ECX]; trace_vmport_command(command); if (command >=3D VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - return eax; + goto out; + } + + eax =3D s->func[command](s->opaque[command], addr); + +out: + /* + * The call above to cpu_synchronize_state() gets vCPU registers values + * to QEMU but also cause QEMU to write QEMU vCPU registers values to + * vCPU implementation (e.g. Accelerator such as KVM) just before + * resuming guest. + * + * Therefore, in order to make IOPort return value propagate to + * guest EAX, we need to explicitly update QEMU EAX register value. + */ + if (s->compat_flags & VMPORT_COMPAT_READ_SET_EAX) { + cpu->env.regs[R_EAX] =3D eax; } =20 - return s->func[command](s->opaque[command], addr); + return eax; } =20 static void vmport_ioport_write(void *opaque, hwaddr addr, @@ -142,6 +165,9 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) } =20 static Property vmport_properties[] =3D { + /* Used to enforce compatibility for migration */ + DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags, + VMPORT_COMPAT_READ_SET_EAX_BIT, true), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905324; cv=none; d=zohomail.com; s=zohoarc; b=F0hvfSVWurFZ9se1OHZnThq9LQt5wmvMG9w9GBvL626kEGxw/1bthxstAYDbnS8ZIGlBoIxNpxmMSwXVksRWknkUnB7UWmQZ7iMokj8mRiOEvawN6zj+tBVPoEp9NhAznR6zx/JlHvQmH3n4PsEQSoUwjf5Qjcz5wONpFR0iWFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905324; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W8CCQCgktXrkBHo81PhmgZOSOA7dyv1hYupPwxhHiIg=; b=YaeXA1bFgBFUTCS6dUQ0Onrm0AT2tPjxz+cPO9BMtH1KMDOO+CplRyPiCqOshfl/9GxzCcrm4VhrYNdBrs8xKufZ9elqPliHoFeht7lp8y3QupqoiKk2ZP+40XaAYKNRfcE6gMLYPH3lUR1wAVJJuIWRqu4Yt6XRe66JUa+LCFI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905324463605.0890930437228; Thu, 11 Jun 2020 12:55:24 -0700 (PDT) Received: from localhost ([::1]:48168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTIJ-0005RN-2Y for importer@patchew.org; Thu, 11 Jun 2020 15:55:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8c-0007cC-Lk for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:23 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:24568 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8a-0000w6-5Y for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-129-ma5VKT5UPlGT_bAm3s80sw-1; Thu, 11 Jun 2020 15:45:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C81F5461; Thu, 11 Jun 2020 19:45:15 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 736F85D9DC; Thu, 11 Jun 2020 19:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904719; 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=W8CCQCgktXrkBHo81PhmgZOSOA7dyv1hYupPwxhHiIg=; b=CY8Teg0o9AUjcroRMXb9O/nvRpyQ9pm8xdqJd15tn2XxcFJMl3Z7BNGX/5+B9poKPULnAQ gjUqpYCr/TXnYPUw8kTiTVoxvUQOnUHhnpey3yuTXcPJEa+TSmfFQbAhoX6cJWC+39Ojy2 o1NLLn2HTQSyxvTZ8tHRAZX+L22QS+Y= X-MC-Unique: ma5VKT5UPlGT_bAm3s80sw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 028/115] hw/i386/vmport: Set EAX to -1 on failed and unsupported commands Date: Thu, 11 Jun 2020 15:43:22 -0400 Message-Id: <20200611194449.31468-29-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon This is used as a signal for VMware Tools to know if a command it attempted to invoke, failed or is unsupported. As a result, VMware Tools will either report failure to user or fallback to another backdoor command in attempt to perform some operation. A few examples: * open-vm-tools TimeSyncReadHost() function fallbacks to CMD_GETTIMEFULL command when CMD_GETTIMEFULL_WITH_LAG fails/unsupported. * open-vm-tools Hostinfo_NestingSupported() function verifies EAX !=3D -1 to check for success. * open-vm-tools Hostinfo_VCPUInfoBackdoor() functions checks if reserved-bit is set to indicate command is unimplemented. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-5-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + hw/i386/vmport.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 83f0fe5c91..fc209d711b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -44,6 +44,7 @@ GlobalProperty hw_compat_4_2[] =3D { { "qxl-vga", "revision", "4" }, { "fw_cfg", "acpi-mr-restore", "false" }, { "vmport", "x-read-set-eax", "off" }, + { "vmport", "x-signal-unsupported-cmd", "off" }, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 3bb420a245..730b61fcaa 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -44,9 +44,12 @@ #define VMPORT_MAGIC 0x564D5868 =20 /* Compatibility flags for migration */ -#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 -#define VMPORT_COMPAT_READ_SET_EAX \ +#define VMPORT_COMPAT_READ_SET_EAX_BIT 0 +#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 +#define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) +#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ + (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT) =20 #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 @@ -87,17 +90,23 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, =20 eax =3D env->regs[R_EAX]; if (eax !=3D VMPORT_MAGIC) { - goto out; + goto err; } =20 command =3D env->regs[R_ECX]; trace_vmport_command(command); if (command >=3D VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - goto out; + goto err; } =20 eax =3D s->func[command](s->opaque[command], addr); + goto out; + +err: + if (s->compat_flags & VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD) { + eax =3D UINT32_MAX; + } =20 out: /* @@ -168,6 +177,8 @@ static Property vmport_properties[] =3D { /* Used to enforce compatibility for migration */ DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags, VMPORT_COMPAT_READ_SET_EAX_BIT, true), + DEFINE_PROP_BIT("x-signal-unsupported-cmd", VMPortState, compat_flags, + VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905648; cv=none; d=zohomail.com; s=zohoarc; b=SUooHVWrP1skGjZVWtIvxjRG6yilZMZyJvOKSMhUKWlZtZZ3bvEHhE6gSgZnBXI6TU+565Ec4EjKCw4ifq89xPpmQzWMBVo3Xq2lQXTTb62UZhWv2/gfjBVKbES7o8M6Gg380RbVQ7MaKBD21uaO9ntIm1pcOQQrXCdLmCZGeog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905648; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iwfsifuosc1Hr9eoc0Zlhiw1A6ToPZpXeqtV05HpnVc=; b=hg6Q6EigVyEkAMpuKjoXc2BsEDliX55x7RDL5y9QpabiiXk97VJBmTI7s9c34ptnqoPd1QuiW5MZObWHC7QLSUp9Ol+iNSqzf6egL7PXx3p73b6Q0pagYlN1GL1/NkkyNGKXNWrQRL4kInO+pM+rpYDTWqeSbNJg+N6B6Mop5uU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905648650943.5046809212128; Thu, 11 Jun 2020 13:00:48 -0700 (PDT) Received: from localhost ([::1]:36820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTNX-00051f-2i for importer@patchew.org; Thu, 11 Jun 2020 16:00:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8e-0007ct-3d for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48467 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8a-0000wV-Ox for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-LQqjEWeDOKqLz0VMgejBEA-1; Thu, 11 Jun 2020 15:45:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 569A1A0C00; Thu, 11 Jun 2020 19:45:16 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E53195D9DC; Thu, 11 Jun 2020 19:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904719; 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=iwfsifuosc1Hr9eoc0Zlhiw1A6ToPZpXeqtV05HpnVc=; b=hbjK0Qev6vMDj3c5qDC6q+CTfLo1xWtwKmHXafcKyOHhdoOW1Q6mqxVODBtG5a7HPD4iLL 7z/wsjZoJM+fCIV+BKHvHtuImlloUOK6be0F4IbYr+ratjAi4HIxRoJIXxLYuPjbL1Qt+r 5LRz8vXkP7B1RWczjX4LPX6Zd8aHWNk= X-MC-Unique: LQqjEWeDOKqLz0VMgejBEA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 029/115] hw/i386/vmport: Introduce vmware-vmx-version property Date: Thu, 11 Jun 2020 15:43:23 -0400 Message-Id: <20200611194449.31468-30-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Liran Alon vmware-vmx-version is a number returned from CMD_GETVERSION which specifies to guest VMware Tools the the host VMX version. If the host reports a number that is different than what the guest VMware Tools expects, it may force guest to upgrade VMware Tools. (See comment above VERSION_MAGIC and VmCheck_IsVirtualWorld() function in open-vm-tools open-source code). For better readability and allow maintaining compatability for guests which may expect different vmware-vmx-version, make vmware-vmx-version a VMPort object property. This would allow user to control it's value via "-global vmport.vmware-vmx-version=3DX". Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200312165431.82118-6-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 730b61fcaa..dfebaf5b73 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -60,6 +60,8 @@ typedef struct VMPortState { VMPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; =20 + uint32_t vmware_vmx_version; + uint32_t compat_flags; } VMPortState; =20 @@ -138,7 +140,7 @@ static uint32_t vmport_cmd_get_version(void *opaque, ui= nt32_t addr) X86CPU *cpu =3D X86_CPU(current_cpu); =20 cpu->env.regs[R_EBX] =3D VMPORT_MAGIC; - return 6; + return port_state->vmware_vmx_version; } =20 static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) @@ -179,6 +181,11 @@ static Property vmport_properties[] =3D { VMPORT_COMPAT_READ_SET_EAX_BIT, true), DEFINE_PROP_BIT("x-signal-unsupported-cmd", VMPortState, compat_flags, VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true), + + /* Default value taken from open-vm-tools code VERSION_MAGIC definitio= n */ + DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState, + vmware_vmx_version, 6), + DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907313; cv=none; d=zohomail.com; s=zohoarc; b=Gro+HXFi+TTctDGhanqklz3WJyRlcYhwlLb0KeG70k9r24quNj1HLhrVuJktm1Im7rjDiCZkvYQFfSWr6mLEg4wtoXFQB9bm9EwHWh6drJmoAHntmuIYO8mB6Urzt3LVRwoXopCfo3Q9N8grE0ICgV9JL4JyR6QT2HkRz7+keFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907313; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1F3nfkmKEdCTdED+n1i08y1sAXEB2o5OWQH399iTe9w=; b=YOaBzY6l6lU39xSy6yG5mhEWz3JILDiNrrBzKddwMfA9IiQO3xSmhx82vI06cH8k29YAchAjjCIDabShsyXwSDqlhaBR20ex8sS0Y7lHZIhmVtvR8rah/w8hEBVTAcZ4a5unrXJjydekJdOQXpxRXmfxMJi1WZuLc8aTStVd96k= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907313881900.3503675048968; Thu, 11 Jun 2020 13:28:33 -0700 (PDT) Received: from localhost ([::1]:51548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjToO-0002HU-FP for importer@patchew.org; Thu, 11 Jun 2020 16:28:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9I-0008AB-Ii for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53293 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9F-0001Ca-1P for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-2tDgYAk8O0mKOT4zMIWi2A-1; Thu, 11 Jun 2020 15:45:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67A60A0C04; Thu, 11 Jun 2020 19:45:17 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDE2E7E591; Thu, 11 Jun 2020 19:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904758; 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=1F3nfkmKEdCTdED+n1i08y1sAXEB2o5OWQH399iTe9w=; b=J1CwaySqzUuOaP8wWW7LVZLntBfI1uHJKF3ZSBf/jUQwn75Riez2xld9hQR0idzoe31c4G GzJ0fd68e7/nzufJrG00iEakJ3RcYn1KeC2UsYMNTbwUZMYQQi/TF1K4OmcshYwsPJLSr+ 7gFyBpET0E+B9OF/oSxzKBtjK/wHWr8= X-MC-Unique: 2tDgYAk8O0mKOT4zMIWi2A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 030/115] hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION Date: Thu, 11 Jun 2020 15:43:24 -0400 Message-Id: <20200611194449.31468-31-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon As can be seen from VmCheck_GetVersion() in open-vm-tools code, CMD_GETVERSION should return vmware-vmx-type in ECX register. Default is to fake host as VMware ESX server. But user can control this value by "-global vmport.vmware-vmx-type=3DX". Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-7-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + hw/i386/vmport.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index fc209d711b..9a07e9333a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -45,6 +45,7 @@ GlobalProperty hw_compat_4_2[] =3D { { "fw_cfg", "acpi-mr-restore", "false" }, { "vmport", "x-read-set-eax", "off" }, { "vmport", "x-signal-unsupported-cmd", "off" }, + { "vmport", "x-report-vmx-type", "off" }, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index dfebaf5b73..dabb443367 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -46,10 +46,13 @@ /* Compatibility flags for migration */ #define VMPORT_COMPAT_READ_SET_EAX_BIT 0 #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 +#define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2 #define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT) +#define VMPORT_COMPAT_REPORT_VMX_TYPE \ + (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT) =20 #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 @@ -61,6 +64,7 @@ typedef struct VMPortState { void *opaque[VMPORT_ENTRIES]; =20 uint32_t vmware_vmx_version; + uint8_t vmware_vmx_type; =20 uint32_t compat_flags; } VMPortState; @@ -140,6 +144,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, ui= nt32_t addr) X86CPU *cpu =3D X86_CPU(current_cpu); =20 cpu->env.regs[R_EBX] =3D VMPORT_MAGIC; + if (port_state->compat_flags & VMPORT_COMPAT_REPORT_VMX_TYPE) { + cpu->env.regs[R_ECX] =3D port_state->vmware_vmx_type; + } return port_state->vmware_vmx_version; } =20 @@ -181,10 +188,30 @@ static Property vmport_properties[] =3D { VMPORT_COMPAT_READ_SET_EAX_BIT, true), DEFINE_PROP_BIT("x-signal-unsupported-cmd", VMPortState, compat_flags, VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true), + DEFINE_PROP_BIT("x-report-vmx-type", VMPortState, compat_flags, + VMPORT_COMPAT_REPORT_VMX_TYPE_BIT, true), =20 /* Default value taken from open-vm-tools code VERSION_MAGIC definitio= n */ DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState, vmware_vmx_version, 6), + /* + * Value determines which VMware product type host report itself to gu= est. + * + * Most guests are fine with exposing host as VMware ESX server. + * Some legacy/proprietary guests hard-code a given type. + * + * For a complete list of values, refer to enum VMXType at open-vm-too= ls + * project (Defined at lib/include/vm_vmx_type.h). + * + * Reasonable options: + * 0 - Unset + * 1 - VMware Express (deprecated) + * 2 - VMware ESX Server + * 3 - VMware Server (Deprecated) + * 4 - VMware Workstation + * 5 - ACE 1.x (Deprecated) + */ + DEFINE_PROP_UINT8("vmware-vmx-type", VMPortState, vmware_vmx_type, 2), =20 DEFINE_PROP_END_OF_LIST(), }; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906561; cv=none; d=zohomail.com; s=zohoarc; b=NQTH4u5zU8tw3YM+ujPHRtsUX5QE9/FTkh9JLwQklGFVekTTs04p3QYdvCa4o0W3Gx1+omMDT+c8GIX6xs2GfUVkZwQywHQ6hy4DOiehSS1a3gZ+El+zFbW7MXsc3JmSctDm504TcyArt+lxzWzoNqWXFUVFk84UxBGLTK8/LXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906561; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2gaH1ZQGN53/iF7xNq/mMf5LRKAb3Vzs9AKRw7DAhI0=; b=E1jfaTJjgv25iK69G5DF0rpqVC4aHMzBU2H/0Ib1PiAfRS3NyGC2UoNJ1/HoSRBJTVRBRkHewJChbKZ0HWVidOfE2+yzaAzk+QzAMCJi2ZQi7wB8RJEZEoOKm/i2218LYQUI7CCOhOCRGSxTYiEjK2BMna3cJu8hRyFrpWRBTPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190656161742.043568084554636; Thu, 11 Jun 2020 13:16:01 -0700 (PDT) Received: from localhost ([::1]:60672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTcG-00050L-Ds for importer@patchew.org; Thu, 11 Jun 2020 16:16:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9n-0000e7-2M for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:35 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42874 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9i-0001Iw-4S for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-TMqlUCK0Oju2jQXx2EYUwg-1; Thu, 11 Jun 2020 15:45:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE51719057A1; Thu, 11 Jun 2020 19:45:20 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E8997BA1A; Thu, 11 Jun 2020 19:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904789; 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=2gaH1ZQGN53/iF7xNq/mMf5LRKAb3Vzs9AKRw7DAhI0=; b=EXvxeob1HA5a4MdwBJBaZLCwX7na/RjsAE9Ga92ncmRbQzUpd0dXqsoc2TVyR4HlF4VLi+ Y2F2uzsWkpKBNLKo/LnD9pGnQLU94iRYcI3fYvaoxR7T/YiHspRSVL4pN44IsORxaYkuRX MhWpDg/3oRYI3hgs1LtfL7YULHipUFI= X-MC-Unique: TMqlUCK0Oju2jQXx2EYUwg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 031/115] hw/i386/vmport: Introduce vmport.h Date: Thu, 11 Jun 2020 15:43:25 -0400 Message-Id: <20200611194449.31468-32-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Liran Alon , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Liran Alon No functional change. This is mere refactoring. Suggested-by: Michael S. Tsirkin Signed-off-by: Liran Alon Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200312165431.82118-8-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 2 +- hw/i386/vmmouse.c | 2 +- hw/i386/vmport.c | 2 +- hw/i386/vmport.h | 34 ---------------------------------- include/hw/i386/vmport.h | 16 ++++++++++++++++ 5 files changed, 19 insertions(+), 37 deletions(-) delete mode 100644 hw/i386/vmport.h create mode 100644 include/hw/i386/vmport.h diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2128f3d6fe..b9961b1035 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -31,6 +31,7 @@ #include "hw/i386/apic.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" +#include "hw/i386/vmport.h" #include "sysemu/cpus.h" #include "hw/block/fdc.h" #include "hw/ide.h" @@ -91,7 +92,6 @@ #include "qapi/qmp/qerror.h" #include "config-devices.h" #include "e820_memory_layout.h" -#include "vmport.h" #include "fw_cfg.h" #include "trace.h" =20 diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index b3aef41327..b73f076753 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -25,10 +25,10 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "ui/console.h" +#include "hw/i386/vmport.h" #include "hw/input/i8042.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" -#include "vmport.h" #include "cpu.h" =20 /* debug only vmmouse */ diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index dabb443367..e6d169566d 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -30,10 +30,10 @@ =20 #include "qemu/osdep.h" #include "hw/isa/isa.h" +#include "hw/i386/vmport.h" #include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" -#include "vmport.h" #include "cpu.h" #include "trace.h" =20 diff --git a/hw/i386/vmport.h b/hw/i386/vmport.h deleted file mode 100644 index 47eda7a22b..0000000000 --- a/hw/i386/vmport.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * QEMU VMPort emulation - * - * Copyright (C) 2007 Herv=C3=A9 Poussineau - * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. - */ - -#ifndef HW_I386_VMPORT_H -#define HW_I386_VMPORT_H - -#define TYPE_VMPORT "vmport" - -typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); - -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); - -#endif diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h new file mode 100644 index 0000000000..efbe3e0e3f --- /dev/null +++ b/include/hw/i386/vmport.h @@ -0,0 +1,16 @@ +#ifndef HW_VMPORT_H +#define HW_VMPORT_H + +#include "hw/isa/isa.h" + +#define TYPE_VMPORT "vmport" +typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); + +static inline void vmport_init(ISABus *bus) +{ + isa_create_simple(bus, TYPE_VMPORT); +} + +void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); + +#endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905683; cv=none; d=zohomail.com; s=zohoarc; b=E3L96aN+rHQ0nvvcAEtLbHtSbWkZq6Xxr+XcKL47peIkbtfZVRQLCZptvove42R0g34sAHXXbDKOIZPzBx8M+RevXVVuhkIq4GtwnmkFmZUxr8VMGLfCEILGF8vy5jpzVr00QJE6JLuAxc0Ac/s5yzSMUjwnFoWD68sskOSqN6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905683; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o7ERHdN4iEb7/q9LObdRVPQ2Shiyg7n3Z4Gh4J1WRik=; b=gl1zUIig6W9h4UvmrY7zkGuOQx15aOBs03QfTcUGM74ED7yQ7G4/+mbvOfmXFxBPXpqTuPMNgfcc7E6miaN4/h+YHxispE7xfWIkg9ig6/+GbOVPyfzONWE2PpG0c1gk7s16tuQe7YZBC2hTKqDa9hb2nrtSytDwdiT+eEz1cvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905683970737.5600600314548; Thu, 11 Jun 2020 13:01:23 -0700 (PDT) Received: from localhost ([::1]:37470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTO6-0005Sy-KD for importer@patchew.org; Thu, 11 Jun 2020 16:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8l-0007nD-2a for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38966 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8h-0000yu-DV for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-i5SUaUhzOGGz5r6xZeG47A-1; Thu, 11 Jun 2020 15:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73A448018A5; Thu, 11 Jun 2020 19:45:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E9E7BA1A; Thu, 11 Jun 2020 19:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904726; 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=o7ERHdN4iEb7/q9LObdRVPQ2Shiyg7n3Z4Gh4J1WRik=; b=UZTWv9tcVi5aSr0hzw23BAYU/ykizPBOmI8IG/ArObr+kq0j1KztSpzD+gI/z1Qzp5LsdP GWLBhzfLIstvA+ezNvrCfOnty3TYHQSfGG/jCXyUgRjE4R3S7i57aBK37u4yMHYrxamLwc 4B9UpbsGPp4SV25tmmYnfESHt2FY6Hg= X-MC-Unique: i5SUaUhzOGGz5r6xZeG47A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 032/115] hw/i386/vmport: Define enum for all commands Date: Thu, 11 Jun 2020 15:43:26 -0400 Message-Id: <20200611194449.31468-33-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Liran Alon No functional change. Defining an enum for all VMPort commands have the following advantages: * It gets rid of the error-prone requirement to update VMPORT_ENTRIES when new VMPort commands are added to QEMU. * It makes it clear to know by looking at one place at the source, what are all the VMPort commands supported by QEMU. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200312165431.82118-9-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmmouse.c | 18 ++++++------------ hw/i386/vmport.c | 11 ++--------- include/hw/i386/vmport.h | 11 ++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index b73f076753..ba5c987bd2 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -34,12 +34,6 @@ /* debug only vmmouse */ //#define DEBUG_VMMOUSE =20 -/* VMMouse Commands */ -#define VMMOUSE_GETVERSION 10 -#define VMMOUSE_DATA 39 -#define VMMOUSE_STATUS 40 -#define VMMOUSE_COMMAND 41 - #define VMMOUSE_READ_ID 0x45414552 #define VMMOUSE_DISABLE 0x000000f5 #define VMMOUSE_REQUEST_RELATIVE 0x4c455252 @@ -217,10 +211,10 @@ static uint32_t vmmouse_ioport_read(void *opaque, uin= t32_t addr) command =3D data[2] & 0xFFFF; =20 switch (command) { - case VMMOUSE_STATUS: + case VMPORT_CMD_VMMOUSE_STATUS: data[0] =3D vmmouse_get_status(s); break; - case VMMOUSE_COMMAND: + case VMPORT_CMD_VMMOUSE_COMMAND: switch (data[1]) { case VMMOUSE_DISABLE: vmmouse_disable(s); @@ -239,7 +233,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint3= 2_t addr) break; } break; - case VMMOUSE_DATA: + case VMPORT_CMD_VMMOUSE_DATA: vmmouse_data(s, data, data[1]); break; default: @@ -296,9 +290,9 @@ static void vmmouse_realizefn(DeviceState *dev, Error *= *errp) return; } =20 - vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_STATUS, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_COMMAND, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_DATA, vmmouse_ioport_read, s); } =20 static Property vmmouse_properties[] =3D { diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index e6d169566d..359cdef1e0 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -37,10 +37,6 @@ #include "cpu.h" #include "trace.h" =20 -#define VMPORT_CMD_GETVERSION 0x0a -#define VMPORT_CMD_GETRAMSIZE 0x14 - -#define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 =20 /* Compatibility flags for migration */ @@ -71,12 +67,9 @@ typedef struct VMPortState { =20 static VMPortState *port_state; =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque) +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque) { - if (command >=3D VMPORT_ENTRIES) { - return; - } - + assert(command < VMPORT_ENTRIES); trace_vmport_register(command, func, opaque); port_state->func[command] =3D func; port_state->opaque[command] =3D opaque; diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index efbe3e0e3f..bbe2c58bf9 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -6,11 +6,20 @@ #define TYPE_VMPORT "vmport" typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); =20 +typedef enum { + VMPORT_CMD_GETVERSION =3D 10, + VMPORT_CMD_GETRAMSIZE =3D 20, + VMPORT_CMD_VMMOUSE_DATA =3D 39, + VMPORT_CMD_VMMOUSE_STATUS =3D 40, + VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_ENTRIES +} VMPortCommand; + static inline void vmport_init(ISABus *bus) { isa_create_simple(bus, TYPE_VMPORT); } =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque); =20 #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905751; cv=none; d=zohomail.com; s=zohoarc; b=BwBz1PCN72kO5IkXmOotecIihROEXA2p90zQAY5wBJyTkE0lha2qqFLBSZ4wbM1ooKhZxfDwAFEssou9rHziKJ7TTlff52228+XaGdN1VF+Kl4acCC5j7K9akCp5e/vbDM4XchjWR747FuML/VpGiyv66YqpoICH4R/nW7Z3I90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905751; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JLwSIiMBjs4NqM2XF+HJcz2FQ6/HNQCBfwuxpCEIsCY=; b=c7A2SSIbnewnWOluyKELXlJt33ROO8y9MtePeGm7SApJfBd94N8diXO6br1/m2Az5ET2FR6PUu1rhxbGg6fwbpTrNrmShbhDnGvbcBFKaVUEiD5Cn/ZnVG+9pfPAwwz24ymA5cuxVbqTg6i06ZoVhV3wAOb1suf9HW1S/MofQmw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905751543814.5261058271765; Thu, 11 Jun 2020 13:02:31 -0700 (PDT) Received: from localhost ([::1]:40684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTPA-0007fJ-4o for importer@patchew.org; Thu, 11 Jun 2020 16:02:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8j-0007kq-NL for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33051 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8g-0000yn-Na for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-g_Y8B4l9OzCFEvsJpvjxcw-1; Thu, 11 Jun 2020 15:45:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 147D01800D41; Thu, 11 Jun 2020 19:45:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AD665EE0E; Thu, 11 Jun 2020 19:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904725; 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=JLwSIiMBjs4NqM2XF+HJcz2FQ6/HNQCBfwuxpCEIsCY=; b=bKRLA2+5nsyPVx9khtGa+7gB4gM3uhcPUGN2ycGBcbr7HhRyg1iWINT2o+5XhcS4rL3I6L u5Yu+Bh4d2xtLrW9ZGk9LNjbTImCrXayT1Cc9NxBsePkIDR3O5MAUCPXiMJ3mEqNQlJOUQ 7O0YSLBfWWGxP94XZtc6+gj9p8mtpwI= X-MC-Unique: g_Y8B4l9OzCFEvsJpvjxcw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 033/115] hw/i386/vmport: Add support for CMD_GETBIOSUUID Date: Thu, 11 Jun 2020 15:43:27 -0400 Message-Id: <20200611194449.31468-34-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon This is VMware documented functionallity that some guests rely on. Returns the BIOS UUID of the current virtual machine. Note that we also introduce a new compatability flag "x-cmds-v2" to make sure to expose new VMPort commands only to new machine-types. This flag will also be used by the following patches that will introduce additional VMPort commands. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-10-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + hw/i386/vmport.c | 22 ++++++++++++++++++++++ include/hw/i386/vmport.h | 1 + 3 files changed, 24 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9a07e9333a..5460e62294 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -46,6 +46,7 @@ GlobalProperty hw_compat_4_2[] =3D { { "vmport", "x-read-set-eax", "off" }, { "vmport", "x-signal-unsupported-cmd", "off" }, { "vmport", "x-report-vmx-type", "off" }, + { "vmport", "x-cmds-v2", "off" }, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 359cdef1e0..8006ff91d4 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -32,6 +32,7 @@ #include "hw/isa/isa.h" #include "hw/i386/vmport.h" #include "hw/qdev-properties.h" +#include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "cpu.h" @@ -43,12 +44,15 @@ #define VMPORT_COMPAT_READ_SET_EAX_BIT 0 #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 #define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2 +#define VMPORT_COMPAT_CMDS_V2_BIT 3 #define VMPORT_COMPAT_READ_SET_EAX \ (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT) #define VMPORT_COMPAT_REPORT_VMX_TYPE \ (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT) +#define VMPORT_COMPAT_CMDS_V2 \ + (1 << VMPORT_COMPAT_CMDS_V2_BIT) =20 #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 @@ -143,6 +147,18 @@ static uint32_t vmport_cmd_get_version(void *opaque, u= int32_t addr) return port_state->vmware_vmx_version; } =20 +static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + uint32_t *uuid_parts =3D (uint32_t *)(qemu_uuid.data); + + cpu->env.regs[R_EAX] =3D le32_to_cpu(uuid_parts[0]); + cpu->env.regs[R_EBX] =3D le32_to_cpu(uuid_parts[1]); + cpu->env.regs[R_ECX] =3D le32_to_cpu(uuid_parts[2]); + cpu->env.regs[R_EDX] =3D le32_to_cpu(uuid_parts[3]); + return cpu->env.regs[R_EAX]; +} + static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); @@ -170,9 +186,13 @@ static void vmport_realizefn(DeviceState *dev, Error *= *errp) isa_register_ioport(isadev, &s->io, 0x5658); =20 port_state =3D s; + /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); + if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) { + vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + } } =20 static Property vmport_properties[] =3D { @@ -183,6 +203,8 @@ static Property vmport_properties[] =3D { VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true), DEFINE_PROP_BIT("x-report-vmx-type", VMPortState, compat_flags, VMPORT_COMPAT_REPORT_VMX_TYPE_BIT, true), + DEFINE_PROP_BIT("x-cmds-v2", VMPortState, compat_flags, + VMPORT_COMPAT_CMDS_V2_BIT, true), =20 /* Default value taken from open-vm-tools code VERSION_MAGIC definitio= n */ DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState, diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index bbe2c58bf9..7f566ccc02 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -8,6 +8,7 @@ typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t ad= dress); =20 typedef enum { VMPORT_CMD_GETVERSION =3D 10, + VMPORT_CMD_GETBIOSUUID =3D 19, VMPORT_CMD_GETRAMSIZE =3D 20, VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906353; cv=none; d=zohomail.com; s=zohoarc; b=oFJ04CaO0263KM1ky/heAsWabSgXYZrID3AQekFA1E9hiApnP7CE1M6bm5sPtooLR4DmBwftkjypPV0SPlEWNb4/eESRuoFYCh1q296MZH2iYaxmLaiL/hhPJ6S+1qs+PJaedhNwyQNIBVcXHSiiRTEs1Aw8I9wd8qVS5CuQceI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906353; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bjlB80Koby3bUcNCP1SMMXQG/Rg7x+AxPJv8cE+Cwoo=; b=b1dnztcGEfAWxVrm7UgwGEve+llUbL+R6p4ENiD81tCfeWgmycbfs2k1yau3THUTV6gnPKR2jK7IqSwqri1D42HWn/rf7Ch70NSzmrxAHHNUN39U+zRx1dDAdHfwd/E8Qlrk0Cb7n54HA/eoNceWqjFBM3G9iM/CR2QDpbw59Vc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190635306182.03866303984444; Thu, 11 Jun 2020 13:12:33 -0700 (PDT) Received: from localhost ([::1]:45794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTYt-0006Ru-CO for importer@patchew.org; Thu, 11 Jun 2020 16:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8u-0007tW-Ds for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28695 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8s-00011u-00 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-194-qN8xpH4gMai0TI1T3yAZPg-1; Thu, 11 Jun 2020 15:45:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A945DA0C01; Thu, 11 Jun 2020 19:45:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B53B7E589; Thu, 11 Jun 2020 19:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904737; 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=bjlB80Koby3bUcNCP1SMMXQG/Rg7x+AxPJv8cE+Cwoo=; b=NSO+amRl1abcnZfhcVOC/mqrjOjKvLR7GFde+tdfyjiztw3YM1xpRx2M7f9mqTL02gzv+C m4LI5cVUjMn8IDcwas+gcomW88In8Aal2r1JXJJ+JydOrv6USb1oONUez0oMS6EGDxh4px /QDNsE+sYNl6+yppj3b4WCdX5bT6XO0= X-MC-Unique: qN8xpH4gMai0TI1T3yAZPg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 034/115] hw/i386/vmport: Add support for CMD_GET_VCPU_INFO Date: Thu, 11 Jun 2020 15:43:28 -0400 Message-Id: <20200611194449.31468-35-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon Command currently returns that it is unimplemented by setting the reserved-bit in it's return value. Following patches will return various useful vCPU information to guest. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-13-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 14 ++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 15 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 8006ff91d4..942a0e94e3 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -54,6 +54,13 @@ #define VMPORT_COMPAT_CMDS_V2 \ (1 << VMPORT_COMPAT_CMDS_V2_BIT) =20 +/* vCPU features reported by CMD_GET_VCPU_INFO */ +#define VCPU_INFO_SLC64_BIT 0 +#define VCPU_INFO_SYNC_VTSCS_BIT 1 +#define VCPU_INFO_HV_REPLAY_OK_BIT 2 +#define VCPU_INFO_LEGACY_X2APIC_BIT 3 +#define VCPU_INFO_RESERVED_BIT 31 + #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 typedef struct VMPortState { @@ -167,6 +174,11 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint= 32_t addr) return ram_size; } =20 +static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) +{ + return 1 << VCPU_INFO_RESERVED_BIT; +} + static const MemoryRegionOps vmport_ops =3D { .read =3D vmport_ioport_read, .write =3D vmport_ioport_write, @@ -192,6 +204,8 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) { vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, + NULL); } } =20 diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 7f566ccc02..7656432358 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -13,6 +13,7 @@ typedef enum { VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_CMD_GET_VCPU_INFO =3D 68, VMPORT_ENTRIES } VMPortCommand; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906152; cv=none; d=zohomail.com; s=zohoarc; b=XfSjThjxIXrDZEsrGaC4jsED4OmTTAY+fiOyixolzKDqNECaToORPIblIcDXdfi1zRLuC1WSgx7e+RYOxxdgTkD/YQUKZy7l/r94ala7l36nOyRwCYcdiWR5Pfesq8mxlM/MNNTIbFoB0mU7BYpQVWBo5yRAd24VPugot5eFbcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906152; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E9wtEOmw2FHl5lxP0ezQdM7JMQVoBoKAz0J5xFT9n+M=; b=FpdYemjEnXoOFfYDfKjnwZAV7/2BARbV22E+PEX22QIJdgFRiFRjQllq4rO06vkZfYLZXjbC3cI683OYSct2mlPDUiOtTAL9q6cn+4RfFeVRQd9C23QyXAdDEQNwz1PL/JwFkIbDIIPiQRhfU9rk9t87PRaPnEsZqM6p7hpUie0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906152928946.0800159409329; Thu, 11 Jun 2020 13:09:12 -0700 (PDT) Received: from localhost ([::1]:34952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTVf-0000Vk-KF for importer@patchew.org; Thu, 11 Jun 2020 16:09:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9R-0008M6-J3 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21306 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9O-0001E9-H6 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-Dk3K1UVCOySfW6RZzIHlqQ-1; Thu, 11 Jun 2020 15:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49C45461; Thu, 11 Jun 2020 19:45:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFEA25EE0E; Thu, 11 Jun 2020 19:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904769; 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=E9wtEOmw2FHl5lxP0ezQdM7JMQVoBoKAz0J5xFT9n+M=; b=fpB75O4PogkezHlzcuMVCyoVTgeOnntYxem9Xj1a6wNE04PtyzGpUKKYKaObk82KlF3ztj xPNjm0lH04YIbZcNw4Grdg79+GZ8vK4cw4FKd13h8ythdH2BDAVe0bPb8Wq+AqvWUsSjUi sQiY5oq5RoS5FUt8ANq8elGRyQ/B4M4= X-MC-Unique: Dk3K1UVCOySfW6RZzIHlqQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 035/115] hw/i386/vmport: Allow x2apic without IR Date: Thu, 11 Jun 2020 15:43:29 -0400 Message-Id: <20200611194449.31468-36-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon Signal to guest that hypervisor supports x2apic without VT-d/IOMMU Interrupt-Remapping support. This allows guest to use x2apic in case all APIC IDs fits in 8-bit (i.e. Max APIC ID < 255). See Linux kernel commit 4cca6ea04d31 ("x86/apic: Allow x2apic without IR on VMware platform") and Linux try_to_enable_x2apic() function. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-14-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 942a0e94e3..21d4ff048a 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -176,7 +176,14 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint= 32_t addr) =20 static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) { - return 1 << VCPU_INFO_RESERVED_BIT; + X86CPU *cpu =3D X86_CPU(current_cpu); + uint32_t ret =3D 0; + + if (cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC) { + ret |=3D 1 << VCPU_INFO_LEGACY_X2APIC_BIT; + } + + return ret; } =20 static const MemoryRegionOps vmport_ops =3D { --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905742; cv=none; d=zohomail.com; s=zohoarc; b=DQazbj55UW3zvLTItwbIYg6gXNiXkW2jRof/kE/h5EqfBmW3I8E1rFXU95SOmNYwUaAN+afrHk5XkMgfZw/6YKoF006uoSYnCfPyvQ8lFU3o7qCNSQQnaiES3nXIiaQKecdqpLXpRjbAL5K2BrHuo+Ks/ZMy0i0RH17jdtqf0I8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905742; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u8jpMjF43FJZaKogljDg+RI/ofGiOXOFtDoRiNOG8As=; b=HOLIPauUNPHGMpFRp4UWRfn6rx/2EE6+eNf9+w4+KrCzEDuslOI93SU781dJSnLMWYk+Dpnc95PKL1dxcycskR9pEX8Y7O5tJ03xVZT+pwbTNUtw+QprUGrKtEiWq4RcYdNVt/KgKNtlNX1dg98VfqRW2NSRfJ+tgcOR9nlrVg0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905742147129.80827126299187; Thu, 11 Jun 2020 13:02:22 -0700 (PDT) Received: from localhost ([::1]:40184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTP2-0007Sw-Lg for importer@patchew.org; Thu, 11 Jun 2020 16:02:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8n-0007oP-98 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:34 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49768 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8i-0000zF-KH for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-sE76toboO7GlCGbnZQkMUA-1; Thu, 11 Jun 2020 15:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD401A0C00; Thu, 11 Jun 2020 19:45:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7011E5EE0E; Thu, 11 Jun 2020 19:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904727; 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=u8jpMjF43FJZaKogljDg+RI/ofGiOXOFtDoRiNOG8As=; b=IRdbiikcUobsUCLUZ9Pd5xddixkyTmj8nC7Gk2e3xJA+ib/zczM2O9fcbnaqTX7Av8ahbH DHZcMS9k6Wp5BmBduRIlXmFEadFdSSyJmH+ZctkmCtGK0Ir/RfJnuIMh2HgSzhzskcvZA5 SneEsre1TqOdGC7Lyi6vHqUYzHln1Ws= X-MC-Unique: sE76toboO7GlCGbnZQkMUA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 036/115] i386/cpu: Store LAPIC bus frequency in CPU structure Date: Thu, 11 Jun 2020 15:43:30 -0400 Message-Id: <20200611194449.31468-37-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon No functional change. This information will be used by following patches. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-15-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/kvm.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 408392dbf6..00d1f4f013 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1584,6 +1584,7 @@ typedef struct CPUX86State { bool tsc_valid; int64_t tsc_khz; int64_t user_tsc_khz; /* for sanity check only */ + uint64_t apic_bus_freq; #if defined(CONFIG_KVM) || defined(CONFIG_HVF) void *xsave_buf; #endif diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 34f838728d..95bbeb424b 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -59,6 +59,10 @@ do { } while (0) #endif =20 +/* From arch/x86/kvm/lapic.h */ +#define KVM_APIC_BUS_CYCLE_NS 1 +#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) + #define MSR_KVM_WALL_CLOCK 0x11 #define MSR_KVM_SYSTEM_TIME 0x12 =20 @@ -1469,6 +1473,8 @@ int kvm_arch_init_vcpu(CPUState *cs) } } =20 + env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; + /* Paravirtualization CPUIDs */ r =3D hyperv_handle_properties(cs, cpuid_data.entries); if (r < 0) { @@ -1773,9 +1779,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c =3D &cpuid_data.entries[cpuid_i++]; c->function =3D KVM_CPUID_SIGNATURE | 0x10; c->eax =3D env->tsc_khz; - /* LAPIC resolution of 1ns (freq: 1GHz) is hardcoded in KVM's - * APIC_BUS_CYCLE_NS */ - c->ebx =3D 1000000; + c->ebx =3D env->apic_bus_freq / 1000; /* Hz to KHz */ c->ecx =3D c->edx =3D 0; =20 c =3D cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906138; cv=none; d=zohomail.com; s=zohoarc; b=ZC4L4/UeHAjhNFyvzI7CmqKMwqrkcImYaE1Lt4RGyFVJsvywxPYQ8MpjhpBk9jyP9N0YWiUVR2McAJgKjSEXLoV1mafuZdEejdSJDamHIFgtCKgqC0M79m+FlvCpmkIqkzvbMVKWsm4z7BYq6DVMnv7rotkAiCEcqVyoDkyUpjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906138; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=80jIdWIohmKCZwgDka14bDOSxMkNCzxoZxn+X7pnK+Q=; b=mg/fdpuMxYLLZ21rRQV2QN/OWs/VppSz75DZM1x2RECH22tBND8RQMvjwLIKzBkFfVjzCYrJS5Rrhyw+4H0YrRYtUN5yTSGLSkYGBDimm8qwKCVHLkYOHXh+zLZX7bwHqdWtNjAgO2KoWLTkOQbc1pL1EESsO67zQPPtouDfwK4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906138797999.9485465148828; Thu, 11 Jun 2020 13:08:58 -0700 (PDT) Received: from localhost ([::1]:33664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTVR-0008Qc-G3 for importer@patchew.org; Thu, 11 Jun 2020 16:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8s-0007so-UQ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:39 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:31164 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8m-00010G-Si for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-93-HJ22LuhANF-vrKrwPZUayQ-1; Thu, 11 Jun 2020 15:45:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D979107ACCA; Thu, 11 Jun 2020 19:45:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 103647BA1A; Thu, 11 Jun 2020 19:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904731; 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=80jIdWIohmKCZwgDka14bDOSxMkNCzxoZxn+X7pnK+Q=; b=QyhpRoqZrHEyZD+6GA6zmQiGyj9g1BNptHtmRo3NrNR5PNUltcMsQyOpXBT+W7/cEOAGbX BoyahjwxfZSJw+GFDxyuOqlBJpRmQflKtHGnU1B+dOrvp8m+5pELKvZy5RkMEjQVlPTard YKS1pnRroo9z3Z8/n88HihW5Cwj16jA= X-MC-Unique: HJ22LuhANF-vrKrwPZUayQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 037/115] hw/i386/vmport: Add support for CMD_GETHZ Date: Thu, 11 Jun 2020 15:43:31 -0400 Message-Id: <20200611194449.31468-38-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon This command returns to guest information on LAPIC bus frequency and TSC frequency. One can see how this interface is used by Linux vmware_platform_setup() introduced in Linux commit 88b094fb8d4f ("x86: Hypervisor detection and get tsc_freq from hypervisor"). Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-16-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 19 +++++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 21d4ff048a..309cfd105b 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -174,6 +174,24 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint= 32_t addr) return ram_size; } =20 +static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + + if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) { + uint64_t tsc_freq =3D (uint64_t)cpu->env.tsc_khz * 1000; + + cpu->env.regs[R_ECX] =3D cpu->env.apic_bus_freq; + cpu->env.regs[R_EBX] =3D (uint32_t)(tsc_freq >> 32); + cpu->env.regs[R_EAX] =3D (uint32_t)tsc_freq; + } else { + /* Signal cmd as not supported */ + cpu->env.regs[R_EBX] =3D UINT32_MAX; + } + + return cpu->env.regs[R_EAX]; +} + static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); @@ -211,6 +229,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) { vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL); vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, NULL); } diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 7656432358..c380b9c1f0 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -13,6 +13,7 @@ typedef enum { VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_CMD_GETHZ =3D 45, VMPORT_CMD_GET_VCPU_INFO =3D 68, VMPORT_ENTRIES } VMPortCommand; --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591905957; cv=none; d=zohomail.com; s=zohoarc; b=In0JrzDtEeUG9X80A2QF4epb7wi/ISHTFnQ153stD8GmmtV4Es3Wy8JhT6P/kAoDTECJhHBXZiD13OKW2eD4ZHz6suHhaBi3jhLCD5t3vJvcIk+u0a/qBo7sv5Xa1AYo3/Lh4EQOjUfPjydNEKeCQXy5dI42B8Q341DiEtKLd0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/fPYISrPwguO+ngXydsq1EkKIQOWmZRvf4qRYRIqqdw=; b=LktkodmM/rAO2VXvFmGlstn2qPNH9qwbibA5sjoo9IUWlMJEBE6Kv08jAZnBqhvrDZMcEQxoaZipiPmJWfrHb6TDr8MMvrrhqAIfH9PSkUzFlw4x5wWNEtHHT9wDcAJImIsfD7/YCdtl9SYY1ieXkP1RqdfolbUCQD/G7ZXghy8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905957245873.4285951486772; Thu, 11 Jun 2020 13:05:57 -0700 (PDT) Received: from localhost ([::1]:49262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTSV-00036g-UQ for importer@patchew.org; Thu, 11 Jun 2020 16:05:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8l-0007nl-HC for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51822 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8j-0000zY-1I for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-jAlw_qcwM16uweMT2iu32A-1; Thu, 11 Jun 2020 15:45:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E065A0C01; Thu, 11 Jun 2020 19:45:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A440B7E589; Thu, 11 Jun 2020 19:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904728; 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=/fPYISrPwguO+ngXydsq1EkKIQOWmZRvf4qRYRIqqdw=; b=UNAuYqvsEvlssfSjC3peIwEr84gGmzkAEqoTFsmGq2d6Aq2mIbY5nO8fbglB0zVVVQFLw1 xRgIo4B7b7J5TMvggIZD4ox2dtDCMae9lDkZHjdxjfdxv2Hx/7ObagweiEl2OePlhUc9iw YAscPuTxNzrnp5mfoPKtU6JjtoxRkV4= X-MC-Unique: jAlw_qcwM16uweMT2iu32A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 038/115] hw/i386/vmport: Assert vmport initialized before registering commands Date: Thu, 11 Jun 2020 15:43:32 -0400 Message-Id: <20200611194449.31468-39-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liran Alon , Nikita Leshenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Liran Alon vmport_register() is also called from other modules such as vmmouse. Therefore, these modules rely that vmport is realized before those call sites. If this is violated, vmport_register() will NULL-deref. To make such issues easier to debug, assert in vmport_register() that vmport is already realized. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Message-Id: <20200312165431.82118-17-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 309cfd105b..79ef25d223 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -81,6 +81,8 @@ static VMPortState *port_state; void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque) { assert(command < VMPORT_ENTRIES); + assert(port_state); + trace_vmport_register(command, func, opaque); port_state->func[command] =3D func; port_state->opaque[command] =3D opaque; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591905941; cv=none; d=zohomail.com; s=zohoarc; b=igb6ETk/7uBfNV41wSLv64NpFdS8OysYGpm53dnIRdZO/tdKkDFUkvH28JGOa5P+/mwMzqhDJvK4up78VNOrvmgxvQBm0k9uJ/veb95hXJpNzxFWMKtZIgrbso6AgGa/w+ru/7qKbMecPvJFFImg8KMIVv0WfkG+74Csf6nvjjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591905941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=epMLqb2E81IffEMXdR4QTZHzWxK+yTE/lQmBwxDH894=; b=NNcdvb6J4JZ3CJsz+TuUneoXb4VOfC42dujZRh7pGl+QSn0lY5kdlHs69AkgmcmlwkG2v4b6bbkkCzVL9jUTcNfxaOjKKfE+9rcK4hn4Fyiujxce525bK3iI51xbwgQD19igGr+UfbqadJXa7I5wEKr50d4aVcDjvW2w3OjujTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591905941349215.6735888514305; Thu, 11 Jun 2020 13:05:41 -0700 (PDT) Received: from localhost ([::1]:48734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTSF-0002tU-ST for importer@patchew.org; Thu, 11 Jun 2020 16:05:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8p-0007pU-FO for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28341 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8m-00010H-M6 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-iMD0dq6wPSa2HBAAqaQXHA-1; Thu, 11 Jun 2020 15:45:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC36C100A8EA; Thu, 11 Jun 2020 19:45:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4550B7E589; Thu, 11 Jun 2020 19:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904731; 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=epMLqb2E81IffEMXdR4QTZHzWxK+yTE/lQmBwxDH894=; b=QTRWiC+FGSr+vFZIQ80Qz4RB0hWObgAF/ScVz52B1LKmE1wb1/QcRoL7HyVYpYpSd0fPC8 mhEcvwPYIxS37PltKRgZ1bLXYlsCOIrbeOgJvsikNm95B5exbNQah7PbyUGdL4CIHAyBUE GIpfISXHUbEUncQHAKv177My8uIs2pw= X-MC-Unique: iMD0dq6wPSa2HBAAqaQXHA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 039/115] accel: Move Xen accelerator code under accel/xen/ Date: Thu, 11 Jun 2020 15:43:33 -0400 Message-Id: <20200611194449.31468-40-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paul Durrant Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 This code is not related to hardware emulation. Move it under accel/ with the other hypervisors. Reviewed-by: Paul Durrant Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200508100222.7112-1-philmd@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Paolo Bonzini --- MAINTAINERS | 2 ++ accel/Makefile.objs | 1 + accel/xen/Makefile.objs | 1 + hw/xen/xen-common.c =3D> accel/xen/xen-all.c | 8 +++++ hw/acpi/piix4.c | 2 +- hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/i386/xen/xen-hvm.c | 1 + hw/i386/xen/xen_platform.c | 1 + hw/isa/piix3.c | 1 + hw/pci/msix.c | 1 + hw/xen/Makefile.objs | 2 +- include/exec/ram_addr.h | 2 +- include/hw/xen/xen.h | 11 ------- include/sysemu/xen.h | 38 ++++++++++++++++++++++ migration/savevm.c | 2 +- softmmu/vl.c | 2 +- stubs/xen-hvm.c | 9 ----- target/i386/cpu.c | 2 +- 20 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 accel/xen/Makefile.objs rename hw/xen/xen-common.c =3D> accel/xen/xen-all.c (98%) create mode 100644 include/sysemu/xen.h diff --git a/MAINTAINERS b/MAINTAINERS index 3abe3faa4e..abe4d7ef8a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -440,6 +440,7 @@ M: Paul Durrant L: xen-devel@lists.xenproject.org S: Supported F: */xen* +F: accel/xen/* F: hw/9pfs/xen-9p* F: hw/char/xen_console.c F: hw/display/xenfb.c @@ -453,6 +454,7 @@ F: hw/i386/xen/ F: hw/pci-host/xen_igd_pt.c F: include/hw/block/dataplane/xen* F: include/hw/xen/ +F: include/sysemu/xen.h F: include/sysemu/xen-mapcache.h =20 Guest CPU Cores (HAXM) diff --git a/accel/Makefile.objs b/accel/Makefile.objs index 17e5ac6061..ff72f0d030 100644 --- a/accel/Makefile.objs +++ b/accel/Makefile.objs @@ -2,4 +2,5 @@ common-obj-$(CONFIG_SOFTMMU) +=3D accel.o obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) +=3D qtest.o obj-$(CONFIG_KVM) +=3D kvm/ obj-$(CONFIG_TCG) +=3D tcg/ +obj-$(CONFIG_XEN) +=3D xen/ obj-y +=3D stubs/ diff --git a/accel/xen/Makefile.objs b/accel/xen/Makefile.objs new file mode 100644 index 0000000000..7482cfb436 --- /dev/null +++ b/accel/xen/Makefile.objs @@ -0,0 +1 @@ +obj-y +=3D xen-all.o diff --git a/hw/xen/xen-common.c b/accel/xen/xen-all.c similarity index 98% rename from hw/xen/xen-common.c rename to accel/xen/xen-all.c index 70564cc952..f3edc65ec9 100644 --- a/hw/xen/xen-common.c +++ b/accel/xen/xen-all.c @@ -16,6 +16,7 @@ #include "hw/xen/xen_pt.h" #include "chardev/char.h" #include "sysemu/accel.h" +#include "sysemu/xen.h" #include "sysemu/runstate.h" #include "migration/misc.h" #include "migration/global_state.h" @@ -31,6 +32,13 @@ do { } while (0) #endif =20 +static bool xen_allowed; + +bool xen_enabled(void) +{ + return xen_allowed; +} + xc_interface *xen_xc; xenforeignmemory_handle *xen_fmem; xendevicemodel_handle *xen_dmod; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 85c199b30d..e27f57195a 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -30,6 +30,7 @@ #include "hw/acpi/acpi.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "qapi/error.h" #include "qemu/range.h" #include "exec/address-spaces.h" @@ -41,7 +42,6 @@ #include "hw/mem/nvdimm.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" -#include "hw/xen/xen.h" #include "migration/vmstate.h" #include "hw/core/cpu.h" #include "trace.h" diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b9961b1035..143ac1c354 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -57,6 +57,7 @@ #include "sysemu/tcg.h" #include "sysemu/numa.h" #include "sysemu/kvm.h" +#include "sysemu/xen.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2613d25bda..eea964e72b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -53,6 +53,7 @@ #include "cpu.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "sysemu/xen.h" #ifdef CONFIG_XEN #include #include "hw/xen/xen_pt.h" diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 688d57ddf3..fa9ef449d1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -36,6 +36,7 @@ #include "hw/rtc/mc146818rtc.h" #include "hw/xen/xen.h" #include "sysemu/kvm.h" +#include "sysemu/xen.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h" diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 82ece6b9e7..041303a2fa 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -28,6 +28,7 @@ #include "qemu/range.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "sysemu/xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h" diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 0f7b05e5e1..a1492fdecd 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -33,6 +33,7 @@ #include "hw/xen/xen-legacy-backend.h" #include "trace.h" #include "exec/address-spaces.h" +#include "sysemu/xen.h" #include "sysemu/block-backend.h" #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index fd1c78879f..1a5267e19f 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -28,6 +28,7 @@ #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 29187898f2..2c7ead7667 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -19,6 +19,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pci.h" #include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "qemu/range.h" diff --git a/hw/xen/Makefile.objs b/hw/xen/Makefile.objs index 84df60a928..340b2c5096 100644 --- a/hw/xen/Makefile.objs +++ b/hw/xen/Makefile.objs @@ -1,5 +1,5 @@ # xen backend driver support -common-obj-$(CONFIG_XEN) +=3D xen-legacy-backend.o xen_devconfig.o xen_pvd= ev.o xen-common.o xen-bus.o xen-bus-helper.o xen-backend.o +common-obj-$(CONFIG_XEN) +=3D xen-legacy-backend.o xen_devconfig.o xen_pvd= ev.o xen-bus.o xen-bus-helper.o xen-backend.o =20 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) +=3D xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) +=3D xen_pt.o xen_pt_config_init.o xen_p= t_graphics.o xen_pt_msi.o diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b295f6a784..7b5c24e928 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -21,7 +21,7 @@ =20 #ifndef CONFIG_USER_ONLY #include "cpu.h" -#include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "sysemu/tcg.h" #include "exec/ramlist.h" #include "exec/ramblock.h" diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 5ac1c6dc55..771dd447f2 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -20,13 +20,6 @@ extern uint32_t xen_domid; extern enum xen_mode xen_mode; extern bool xen_domid_restrict; =20 -extern bool xen_allowed; - -static inline bool xen_enabled(void) -{ - return xen_allowed; -} - int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); void xen_piix3_set_irq(void *opaque, int irq_num, int level); void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int = len); @@ -39,10 +32,6 @@ void xenstore_store_pv_console_info(int i, struct Charde= v *chr); =20 void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory); =20 -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, - struct MemoryRegion *mr, Error **errp); -void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); - void xen_register_framebuffer(struct MemoryRegion *mr); =20 #endif /* QEMU_HW_XEN_H */ diff --git a/include/sysemu/xen.h b/include/sysemu/xen.h new file mode 100644 index 0000000000..1ca292715e --- /dev/null +++ b/include/sysemu/xen.h @@ -0,0 +1,38 @@ +/* + * QEMU Xen support + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef SYSEMU_XEN_H +#define SYSEMU_XEN_H + +#ifdef CONFIG_XEN + +bool xen_enabled(void); + +#ifndef CONFIG_USER_ONLY +void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, + struct MemoryRegion *mr, Error **errp); +#endif + +#else /* !CONFIG_XEN */ + +#define xen_enabled() 0 +#ifndef CONFIG_USER_ONLY +static inline void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t le= ngth) +{ + /* nothing */ +} +static inline void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, + MemoryRegion *mr, Error **errp) +{ + g_assert_not_reached(); +} +#endif + +#endif /* CONFIG_XEN */ + +#endif diff --git a/migration/savevm.c b/migration/savevm.c index c00a6807d9..b979ea6e7f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -28,7 +28,6 @@ =20 #include "qemu/osdep.h" #include "hw/boards.h" -#include "hw/xen/xen.h" #include "net/net.h" #include "migration.h" #include "migration/snapshot.h" @@ -59,6 +58,7 @@ #include "sysemu/replay.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/xen.h" #include "qjson.h" #include "migration/colo.h" #include "qemu/bitmap.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index 055472da66..f669c06ede 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -36,6 +36,7 @@ #include "sysemu/runstate.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" +#include "sysemu/xen.h" =20 #include "qemu/error-report.h" #include "qemu/sockets.h" @@ -178,7 +179,6 @@ static NotifierList exit_notifiers =3D static NotifierList machine_init_done_notifiers =3D NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); =20 -bool xen_allowed; uint32_t xen_domid; enum xen_mode xen_mode =3D XEN_EMULATE; bool xen_domid_restrict; diff --git a/stubs/xen-hvm.c b/stubs/xen-hvm.c index b7d53b5e2f..6954a5b696 100644 --- a/stubs/xen-hvm.c +++ b/stubs/xen-hvm.c @@ -35,11 +35,6 @@ int xen_is_pirq_msi(uint32_t msi_data) return 0; } =20 -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, - Error **errp) -{ -} - qemu_irq *xen_interrupt_controller_init(void) { return NULL; @@ -49,10 +44,6 @@ void xen_register_framebuffer(MemoryRegion *mr) { } =20 -void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) -{ -} - void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 25a8f6b1ad..b5705cda86 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -29,6 +29,7 @@ #include "sysemu/reset.h" #include "sysemu/hvf.h" #include "sysemu/cpus.h" +#include "sysemu/xen.h" #include "kvm_i386.h" #include "sev_i386.h" =20 @@ -54,7 +55,6 @@ #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY #include "exec/address-spaces.h" -#include "hw/xen/xen.h" #include "hw/i386/apic_internal.h" #include "hw/boards.h" #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907918; cv=none; d=zohomail.com; s=zohoarc; b=OoOwa+Q6vO2bFlc1qzW8+U4o3eTljZAvt5jzdC4Z/0MCPT1MU5EKz0lahnBFxDHeGf4nb4PvDnzhb1Z/3ZgU17nn2nbGyU86h2o7sNr9SsKvibRz/Iz93KUDGQgYxATrhX3sU9yokz/J9Dfh81Wn4IHZBq+BfuJRH7zhct5tXXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EOhD+kEwR0sebMN8wXXLh51QpMb6b/YnSudGWFN1vA8=; b=Mg/2VPlbRRM6hQ+jKXLMDQ2HbPmEJ4q0nHbZmyWJwooGn+AWbl5BPKDTn+Dc03R6exImAGZ+iugdywIUQTjPG6yIBR/YIheZEkOhzRvnjJLbWfpqBNUMyr8tBozDJvvtHx+8Q7B9shvWFO5CXYxX6JoBmZ5nZY6ZKxxskvNKyaw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907918928786.48816516401; Thu, 11 Jun 2020 13:38:38 -0700 (PDT) Received: from localhost ([::1]:58266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTy9-0002gc-KI for importer@patchew.org; Thu, 11 Jun 2020 16:38:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA1-0001A6-1g for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52709 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9z-0001K1-5N for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-ql388yY0NtitnaJADjIubQ-1; Thu, 11 Jun 2020 15:45:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8526100A8EC; Thu, 11 Jun 2020 19:45:26 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 936E35C1B2; Thu, 11 Jun 2020 19:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904806; 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=EOhD+kEwR0sebMN8wXXLh51QpMb6b/YnSudGWFN1vA8=; b=ErHJ0H+fflcvOFW2CTFxvCSixCwsfUiXt4X6krlUXeVqqO3SO5g3latsXWyrvljcyNkweZ I7ZiDPbkZ3pSj54GGety1kg9D7Mkt/HBAGAaAYCDXuiqevhYCvndXZtm9zIbl54TS/vX7T emITpIfoA6xlcLDJi2IA2gfEFoPYs2w= X-MC-Unique: ql388yY0NtitnaJADjIubQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 040/115] qom: remove index from object_resolve_abs_path() Date: Thu, 11 Jun 2020 15:43:34 -0400 Message-Id: <20200611194449.31468-41-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada You can advance 'parts' to track the current path fragment. The 'index' parameter is unneeded. Signed-off-by: Masahiro Yamada Message-Id: <20200510013235.954906-1-masahiroy@kernel.org> Signed-off-by: Paolo Bonzini --- qom/object.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/qom/object.c b/qom/object.c index 484465f1c8..ea16680051 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1956,26 +1956,25 @@ Object *object_resolve_path_component(Object *paren= t, const char *part) } =20 static Object *object_resolve_abs_path(Object *parent, - char **parts, - const char *typename, - int index) + char **parts, + const char *typename) { Object *child; =20 - if (parts[index] =3D=3D NULL) { + if (*parts =3D=3D NULL) { return object_dynamic_cast(parent, typename); } =20 - if (strcmp(parts[index], "") =3D=3D 0) { - return object_resolve_abs_path(parent, parts, typename, index + 1); + if (strcmp(*parts, "") =3D=3D 0) { + return object_resolve_abs_path(parent, parts + 1, typename); } =20 - child =3D object_resolve_path_component(parent, parts[index]); + child =3D object_resolve_path_component(parent, *parts); if (!child) { return NULL; } =20 - return object_resolve_abs_path(child, parts, typename, index + 1); + return object_resolve_abs_path(child, parts + 1, typename); } =20 static Object *object_resolve_partial_path(Object *parent, @@ -1987,7 +1986,7 @@ static Object *object_resolve_partial_path(Object *pa= rent, GHashTableIter iter; ObjectProperty *prop; =20 - obj =3D object_resolve_abs_path(parent, parts, typename, 0); + obj =3D object_resolve_abs_path(parent, parts, typename); =20 g_hash_table_iter_init(&iter, parent->properties); while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&prop)) { @@ -2032,7 +2031,7 @@ Object *object_resolve_path_type(const char *path, co= nst char *typename, *ambiguousp =3D ambiguous; } } else { - obj =3D object_resolve_abs_path(object_get_root(), parts, typename= , 1); + obj =3D object_resolve_abs_path(object_get_root(), parts + 1, type= name); } =20 g_strfreev(parts); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906459; cv=none; d=zohomail.com; s=zohoarc; b=kCR9Klrd8rynRKKAnN3RyuBtORrhAyRCvIxPPtidbf8MuVKHQCm9z0CBqORqC1NeLkZhAa35WPsm6n0em+Tz8N9owO3m4a0MSV/9eaAwyOH3dN9XFeo/MhIrV8aeBfL5pDqNA7qua7se8PwotV4AxvkixaGJFuILuCZxfGlNIrk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906459; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DTgJDuuIDwGebdq2tlxLGDaJzw2bFUqN/vNtfp59ni4=; b=Jn0rUACXZ246Y2lP70zBkzuWQ3TnhfcCO1PNlisO2nICPUnfASVG+ukFOVw21cPL/kak4Eot5OR5VXIjb/GrbsCzF03ZypssDbjUHC3xRaI8riqPgsEfxLpfs5iRx4elg+8alxMshx0LUjCB+PBjc12lNAOZUUJgmB3I69MX25Q= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906459138894.2561260533556; Thu, 11 Jun 2020 13:14:19 -0700 (PDT) Received: from localhost ([::1]:54140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTab-0002KY-P5 for importer@patchew.org; Thu, 11 Jun 2020 16:14:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8u-0007u8-R0 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:40 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:40262 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8n-00010i-8X for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-wTJgzl4KPEqbItVk2jGkNg-1; Thu, 11 Jun 2020 15:45:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45F22872FEC; Thu, 11 Jun 2020 19:45:27 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 014775C1B2; Thu, 11 Jun 2020 19:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904732; 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=DTgJDuuIDwGebdq2tlxLGDaJzw2bFUqN/vNtfp59ni4=; b=HCkI4v32vW0AVmiLTJn57VLcmliQadEXQi+UyfL3XbqCgZHviXK4TIAZt2WuDyGRoMuHA9 v9Ug7J8Ad9KKh7OAGQTGcf5AAFqYFgYn9ngEjsqEUqZcOYJaBAKDR0qgy82f3Y1+Tel1Mj m1HAxW5sTOERcfN6Fb7+e4T2aBCjYuA= X-MC-Unique: wTJgzl4KPEqbItVk2jGkNg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 041/115] qom/object: factor out the initialization of hash table of properties Date: Thu, 11 Jun 2020 15:43:35 -0400 Message-Id: <20200611194449.31468-42-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada Properties are not related to the initialization of interfaces. The initialization of the hash table can be moved after the if-block, and unified. Signed-off-by: Masahiro Yamada Message-Id: <20200512172615.2291999-1-masahiroy@kernel.org> Signed-off-by: Paolo Bonzini --- qom/object.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qom/object.c b/qom/object.c index ea16680051..a4094a6bb5 100644 --- a/qom/object.c +++ b/qom/object.c @@ -316,8 +316,6 @@ static void type_initialize(TypeImpl *ti) g_assert(parent->instance_size <=3D ti->instance_size); memcpy(ti->class, parent->class, parent->class_size); ti->class->interfaces =3D NULL; - ti->class->properties =3D g_hash_table_new_full( - g_str_hash, g_str_equal, NULL, object_property_free); =20 for (e =3D parent->class->interfaces; e; e =3D e->next) { InterfaceClass *iface =3D e->data; @@ -347,11 +345,11 @@ static void type_initialize(TypeImpl *ti) =20 type_initialize_interface(ti, t, t); } - } else { - ti->class->properties =3D g_hash_table_new_full( - g_str_hash, g_str_equal, NULL, object_property_free); } =20 + ti->class->properties =3D g_hash_table_new_full(g_str_hash, g_str_equa= l, NULL, + object_property_free); + ti->class->type =3D ti; =20 while (parent) { --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906023; cv=none; d=zohomail.com; s=zohoarc; b=IHkjwx7Kx7oGQEJXctpKIgUhSZR6NbqAoUJTLbR5RPVEAsBjP0yPiKGlXfc5yRi6WWq7Jd/DnHr6e7NWxUonQQ0Hwqi5jYdO54HqueVefWt8t/+kUjg3izTJnPWJ/aus1JW5ACHRGdrdbdYiHjLcsYkHGB3XM0Zc0rg5N4ZQ72Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906023; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rxXzaXEGykcs65QPpoMycFH5VB6NEQIChU7kDAJ2bGM=; b=Vc3JVVWE0FlHvexh4+Vopw/5vt9J3YTqtO0ayWZYu2Vc7mtOlR7sHc6To0WPQQKxXCxDNW+8b4IgDAfENnxJBwgY2jRFMXIPAyCedqG5S60/Rqj0AaII0zBpQhyMjystjv0MXMiQZJjbd2z28RfvEJYOJFFvN6m6n7B+Iw7ZMLY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906023152393.3897190538661; Thu, 11 Jun 2020 13:07:03 -0700 (PDT) Received: from localhost ([::1]:53632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTTX-0004yj-OJ for importer@patchew.org; Thu, 11 Jun 2020 16:06:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8o-0007pB-Mb for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:34 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30382 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8m-000103-Hw for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-GqFNGQBmMZOVDL8nVP8wcA-1; Thu, 11 Jun 2020 15:45:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8955872FE0; Thu, 11 Jun 2020 19:45:27 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6304A5C1B2; Thu, 11 Jun 2020 19:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904730; 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=rxXzaXEGykcs65QPpoMycFH5VB6NEQIChU7kDAJ2bGM=; b=UdfJz5dzuHf35DV3ucvT2Kq0cvIjO9g2Nzn3K0ujDv2wVgdJL5WHnPRJgZIHMnLZHwrUUA 1QP34oZGBZ2xaQVQNDvvlU0xLMB5zombanMkBdS/Gv+BgveCynghtRlo07e678389MxPBQ 1Fw9504E8pM2t3O174HqmbyIQut0u5c= X-MC-Unique: GqFNGQBmMZOVDL8nVP8wcA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 042/115] qom/object: simplify type_initialize_interface() Date: Thu, 11 Jun 2020 15:43:36 -0400 Message-Id: <20200611194449.31468-43-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada iface_impl->class is the same as new_iface. Make it more readable. Signed-off-by: Masahiro Yamada Message-Id: <20200512182501.2300530-1-masahiroy@kernel.org> Signed-off-by: Paolo Bonzini --- qom/object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index a4094a6bb5..bc39ad4b99 100644 --- a/qom/object.c +++ b/qom/object.c @@ -262,8 +262,7 @@ static void type_initialize_interface(TypeImpl *ti, Typ= eImpl *interface_type, new_iface->concrete_class =3D ti->class; new_iface->interface_type =3D interface_type; =20 - ti->class->interfaces =3D g_slist_append(ti->class->interfaces, - iface_impl->class); + ti->class->interfaces =3D g_slist_append(ti->class->interfaces, new_if= ace); } =20 static void object_property_free(gpointer data) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906084; cv=none; d=zohomail.com; s=zohoarc; b=cYMabaWvy61eNHXVPG0SXBA/zzknLIUh8cQCqJ6YYcTAiZVRUMMCFGOEnv8LIruHaLcNApJ8IuIU9XizI9dIn21YuGSBpKpiQfS1TvuIHj82oBdCKWlCoHhgJ9g9RdWrSJ1C8KGIzrWUXTn/bX1AgjU1d9AU+5z/97XGI7FUFrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906084; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/d1fb6+JZPNJokrNEuReFcQeKnhzqrR4dIWJFcmCqJ0=; b=Z1SaNlykkMfC8E0YnKaLd99kuphhsmO1VBOza95BFVgCbn7NcuPwq9iKJ8aCVzSj3PkZTwgL4mnszWkmzC/+usF7mO1jMnK2ntDvqGkFRpv8lWyX79qLQ/n3GckcH1Qytyz7UKm/QUJM6UpiFZFPURzXRId0nb5VqGewjRUGhfw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906084645104.25456720465354; Thu, 11 Jun 2020 13:08:04 -0700 (PDT) Received: from localhost ([::1]:58124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTUZ-0006rB-Bm for importer@patchew.org; Thu, 11 Jun 2020 16:08:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8s-0007rj-7d for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42822 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8o-000111-IQ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-cWXKVHEqM1eFaog-MZ9F6g-1; Thu, 11 Jun 2020 15:45:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 160981005512; Thu, 11 Jun 2020 19:45:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C53645C1B2; Thu, 11 Jun 2020 19:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904733; 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=/d1fb6+JZPNJokrNEuReFcQeKnhzqrR4dIWJFcmCqJ0=; b=deRpuOxkvtbkh5hwrkJlJ3qoUbev6sXQV1aLIQzX8f35DFUvBRF/P8mRAb8P6e/sA8cR8t T/EfXRDT3TgMp68OoqnjXUSGjICPyFLmAP8DfpOZci9RoOXktg+NM9jM1UWeGuU9CoPZms b5FZIK7c9/cyjzRrS2J3y1l8tLKnPVc= X-MC-Unique: cWXKVHEqM1eFaog-MZ9F6g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 043/115] qom/object: pass (Object *) to object_initialize_with_type() Date: Thu, 11 Jun 2020 15:43:37 -0400 Message-Id: <20200611194449.31468-44-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada object_new_with_type() already passes (Object *) pointer. Avoid casting back and forth. Signed-off-by: Masahiro Yamada Message-Id: <20200512173104.2293073-1-masahiroy@kernel.org> Signed-off-by: Paolo Bonzini --- qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index bc39ad4b99..b0ed560fd8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -494,10 +494,8 @@ static void object_class_property_init_all(Object *obj) } } =20 -static void object_initialize_with_type(void *data, size_t size, TypeImpl = *type) +static void object_initialize_with_type(Object *obj, size_t size, TypeImpl= *type) { - Object *obj =3D data; - type_initialize(type); =20 g_assert(type->instance_size >=3D sizeof(Object)); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906072; cv=none; d=zohomail.com; s=zohoarc; b=GWw8gor5zuzA4rIc8588zuywbnLk25fyrhBnMeiCJ9w2eFuwM+5HSPWKQMgeFquJtBwQm2gghS9ZezkYCuQfhs9u8HF7ZF5Bt3Nj8aLqmwb1y3E78cwoF9eoINm/0T2F3af4eaFbb496UI8JN8DnIbQZdmkuaPOYv9e6depbnLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906072; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J5NfdnqVKRT8k3HRErJvc0cIEkFqpBZqli3HzxavWPw=; b=ZqfyL/t+AEZQTrgifWnSeO6A9BM9Xf8dqUt1DZR/9YxT1lb5MVteeo9YGcantxf+2H7AI9S9gstCk/ZYFR59yA3Ts/kQLEfmE1QYBbR681T90cz+amP3RCyn5XuxPKsdTYG+WpOTiMLZHYVptzwt0Tu891Nwab9o78w1oeAhRuM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906072947350.57607703393046; Thu, 11 Jun 2020 13:07:52 -0700 (PDT) Received: from localhost ([::1]:57168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTUN-0006TZ-Gw for importer@patchew.org; Thu, 11 Jun 2020 16:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8r-0007qB-Bx for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:37 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35117 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8m-00010V-Nl for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-nxA2KgB2NZeESBlUZ1ar2g-1; Thu, 11 Jun 2020 15:45:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7864D1800D41; Thu, 11 Jun 2020 19:45:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 326745C1B2; Thu, 11 Jun 2020 19:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904731; 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=J5NfdnqVKRT8k3HRErJvc0cIEkFqpBZqli3HzxavWPw=; b=CC4aoNG/drPZLVddyzkhAt069iNQdJiCKVyuGpNHQhouK+DVkRWIuJ01OzJ6HRVq4J4Drm hJCzMPWhzNDRhNcGRxg1L+EuSyAi5Gp8sB5sVmHY65OCjxeZqWP+B7nk07lSAoqKJmZy1f jGCnHajX5ujvdy7RzVlmvaZq9uodDgY= X-MC-Unique: nxA2KgB2NZeESBlUZ1ar2g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 044/115] qom/container: remove .instance_size initializer from container_info Date: Thu, 11 Jun 2020 15:43:38 -0400 Message-Id: <20200611194449.31468-45-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada You can omit .instance_size if it is the same as that of the parent. .class_size =3D sizeof(ObjectClass) ... is omitted here, so removing .instance_size is more consistent. Signed-off-by: Masahiro Yamada Message-Id: <20200513033600.2709646-1-masahiroy@kernel.org> Signed-off-by: Paolo Bonzini --- qom/container.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qom/container.c b/qom/container.c index 14e7ae485b..455e8410c6 100644 --- a/qom/container.c +++ b/qom/container.c @@ -16,7 +16,6 @@ =20 static const TypeInfo container_info =3D { .name =3D "container", - .instance_size =3D sizeof(Object), .parent =3D TYPE_OBJECT, }; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906277; cv=none; d=zohomail.com; s=zohoarc; b=RUA5kl4Yy5kQaMws5FW2xpRv12ACxz9jFhh2910uOnJFH+mQcdt/ENaUj91CCq3KduCxfYM8tHUoqIj6toFEPAFyS/MYFdra3k/qaLqPpGrkq5oSO+HDlpsSMEJ0uQ+x4Gfw0IG1hpHOoqKTxDt5A7Ad1ABTXkwqwYhLrbqgrtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906277; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PMkk8hqdAgfZ2X3p5aW45AQlLiVDJAHPMgDqr+FqlA4=; b=GgIl/UnGxsR6wV9+pXk34s46rl/wD9xIokcy+Q/BgzaSeuBUBlYUNEhOo6Q7T3m7Z2LTDoGXWjCL1tI/BdTgquwyuriU1s3rOAHeK89ZVn+QKa8Vq46ptevi8hArAUKtNGRA6g23w0U/+Up7pZHeqxAZqSnBE5j3b7RhQxfBcWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906277925368.19183648646845; Thu, 11 Jun 2020 13:11:17 -0700 (PDT) Received: from localhost ([::1]:42208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTXg-0004eN-MG for importer@patchew.org; Thu, 11 Jun 2020 16:11:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8u-0007tB-7B for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45904 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8q-00011a-Ua for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-LZ5NVVH0PS-IsE_K_ClniQ-1; Thu, 11 Jun 2020 15:45:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAEA1872FE1 for ; Thu, 11 Jun 2020 19:45:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 955485C1B2; Thu, 11 Jun 2020 19:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904735; 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=PMkk8hqdAgfZ2X3p5aW45AQlLiVDJAHPMgDqr+FqlA4=; b=ZoFnvLxPlXLeuov8xzL1ir8D/QsM+R8gZK1RluZudp/rbThRWv0elhkzMs+HobHOCL+xto K1nC/Ez39iki4fVjS3X5/1u+dgzkQK91Sm32CxuvM9KdqeQf06BQ+WMcMA9CqhjQkUQ+v3 Upb+oL5dzfNWyi1xwBi4GaTNbKnQ53w= X-MC-Unique: LZ5NVVH0PS-IsE_K_ClniQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 045/115] cpus: Fix botched configure_icount() error API violation fix Date: Thu, 11 Jun 2020 15:43:39 -0400 Message-Id: <20200611194449.31468-46-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Markus Armbruster Before recent commit abc9bf69a66, configure_icount() returned early when option "shift" was absent: succeed when option "align" was also absent, else fail. Since then, it still errors out when only "align" is present, but continues when both are absent. Crashes when examining the value of "shift" further. Reproducer: -icount "". Revert this erroneous part of the commit. Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c Fixes: Coverity CID 1428754 Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200515042231.18201-1-armbru@redhat.com> Signed-off-by: Paolo Bonzini --- cpus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 7ce0d569b3..34fc203808 100644 --- a/cpus.c +++ b/cpus.c @@ -821,8 +821,10 @@ void configure_icount(QemuOpts *opts, Error **errp) bool align =3D qemu_opt_get_bool(opts, "align", false); long time_shift =3D -1; =20 - if (!option && qemu_opt_get(opts, "align")) { - error_setg(errp, "Please specify shift option when using align"); + if (!option) { + if (qemu_opt_get(opts, "align") !=3D NULL) { + error_setg(errp, "Please specify shift option when using align= "); + } return; } =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906183; cv=none; d=zohomail.com; s=zohoarc; b=mLWLFpES3zF1ZomEFhopmCKV58Ci1v8ee6WmyrCO1anH/iB5YOTKNbWJ3TPt9O/8CCxol+sVIr4NRSEScEtVX2x5OYmxOm8G85xN+1+xnPSMvwmhlhHEKCdhIi7t78ToY1HzBvsiUDG1YhUfZtscc1YVq9rG/XXZxCj7Q/uZq+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906183; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sLgwJXR/oSCrwqV8wUccJw4DJzCBpLT5U3sULc5EzO4=; b=RNrtFT+Jl4vjsjzm67Ua2qGUpUMd4WCuV6/JrOrp08JwXhZQnjVv9fCiFGRV7t/Mgi0SLhVgb+/x1z0OqelPCu+F9E/zBFzVJspQflo3Jb4nh0AFIwg7zkaX8DX7ZYudEnkp0gGy8ccnaOZZIMWoN/PDhLk9pDHMA5u3/xhNGiM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906183046376.4337742851633; Thu, 11 Jun 2020 13:09:43 -0700 (PDT) Received: from localhost ([::1]:37300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTW9-0001gV-Jn for importer@patchew.org; Thu, 11 Jun 2020 16:09:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8r-0007qn-Pw for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39005 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8n-00010k-BA for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-4uLDJUozPNi9xe57hQu9sg-1; Thu, 11 Jun 2020 15:45:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70BD619057A0; Thu, 11 Jun 2020 19:45:29 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1445F5C1B2; Thu, 11 Jun 2020 19:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904732; 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=sLgwJXR/oSCrwqV8wUccJw4DJzCBpLT5U3sULc5EzO4=; b=MVh4miPVFmDiwi6M+UR33mLotQYynie5M2ozXVEkc+IIITmfOvO6Dckl+rIBl2hPFhBASC Zm3BdFYzQT+sOv0yy976yuta4GbukKGGO9of/tqJ22aPJ8QJa+RJ8qj6KOLkm35WbMUyq6 Med9au8aOpTW2QyaGS8D18LVyIPVq2k= X-MC-Unique: 4uLDJUozPNi9xe57hQu9sg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 046/115] hax: Dynamic allocate vcpu state structure Date: Thu, 11 Jun 2020 15:43:40 -0400 Message-Id: <20200611194449.31468-47-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WangBowen , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: WangBowen Dynamic allocating vcpu state structure according to smp value to be more precise and safe. Previously it will alloccate array of fixed size HAX_MAX_VCPU. This is achieved by using g_new0 to dynamic allocate the array. The allocated size is obtained from smp.max_cpus in MachineState. Also, the size is compared with HAX_MAX_VCPU when creating the vm. The reason for choosing dynamic array over linked list is because the status is visited by index all the time. This will lead to QEMU checking whether the smp value is larger than the HAX_MAX_VCPU when creating vm, if larger, the process will terminate, otherwise it will allocate array of size smp to store the status. V2: Check max_cpus before open vm. (Philippe) Signed-off-by: WangBowen Signed-off-by: Colin Xu Message-Id: <20200509035952.187615-1-colin.xu@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/hax-all.c | 25 +++++++++++++++++++------ target/i386/hax-i386.h | 5 +++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index f9c83fff25..c93bb23a44 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -232,10 +232,10 @@ int hax_init_vcpu(CPUState *cpu) return ret; } =20 -struct hax_vm *hax_vm_create(struct hax_state *hax) +struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus) { struct hax_vm *vm; - int vm_id =3D 0, ret; + int vm_id =3D 0, ret, i; =20 if (hax_invalid_fd(hax->fd)) { return NULL; @@ -245,6 +245,11 @@ struct hax_vm *hax_vm_create(struct hax_state *hax) return hax->vm; } =20 + if (max_cpus > HAX_MAX_VCPU) { + fprintf(stderr, "Maximum VCPU number QEMU supported is %d\n", HAX_= MAX_VCPU); + return NULL; + } + vm =3D g_new0(struct hax_vm, 1); =20 ret =3D hax_host_create_vm(hax, &vm_id); @@ -259,6 +264,12 @@ struct hax_vm *hax_vm_create(struct hax_state *hax) goto error; } =20 + vm->numvcpus =3D max_cpus; + vm->vcpus =3D g_new0(struct hax_vcpu_state *, vm->numvcpus); + for (i =3D 0; i < vm->numvcpus; i++) { + vm->vcpus[i] =3D NULL; + } + hax->vm =3D vm; return vm; =20 @@ -272,12 +283,14 @@ int hax_vm_destroy(struct hax_vm *vm) { int i; =20 - for (i =3D 0; i < HAX_MAX_VCPU; i++) + for (i =3D 0; i < vm->numvcpus; i++) if (vm->vcpus[i]) { fprintf(stderr, "VCPU should be cleaned before vm clean\n"); return -1; } hax_close_fd(vm->fd); + vm->numvcpus =3D 0; + g_free(vm->vcpus); g_free(vm); hax_global.vm =3D NULL; return 0; @@ -292,7 +305,7 @@ static void hax_handle_interrupt(CPUState *cpu, int mas= k) } } =20 -static int hax_init(ram_addr_t ram_size) +static int hax_init(ram_addr_t ram_size, int max_cpus) { struct hax_state *hax =3D NULL; struct hax_qemu_version qversion; @@ -324,7 +337,7 @@ static int hax_init(ram_addr_t ram_size) goto error; } =20 - hax->vm =3D hax_vm_create(hax); + hax->vm =3D hax_vm_create(hax, max_cpus); if (!hax->vm) { fprintf(stderr, "Failed to create HAX VM\n"); ret =3D -EINVAL; @@ -352,7 +365,7 @@ static int hax_init(ram_addr_t ram_size) =20 static int hax_accel_init(MachineState *ms) { - int ret =3D hax_init(ms->ram_size); + int ret =3D hax_init(ms->ram_size, (int)ms->smp.max_cpus); =20 if (ret && (ret !=3D -ENOSPC)) { fprintf(stderr, "No accelerator found.\n"); diff --git a/target/i386/hax-i386.h b/target/i386/hax-i386.h index 54e9d8b057..7d988f81da 100644 --- a/target/i386/hax-i386.h +++ b/target/i386/hax-i386.h @@ -47,7 +47,8 @@ struct hax_state { struct hax_vm { hax_fd fd; int id; - struct hax_vcpu_state *vcpus[HAX_MAX_VCPU]; + int numvcpus; + struct hax_vcpu_state **vcpus; }; =20 #ifdef NEED_CPU_H @@ -58,7 +59,7 @@ int valid_hax_tunnel_size(uint16_t size); /* Host specific functions */ int hax_mod_version(struct hax_state *hax, struct hax_module_version *vers= ion); int hax_inject_interrupt(CPUArchState *env, int vector); -struct hax_vm *hax_vm_create(struct hax_state *hax); +struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus); int hax_vcpu_run(struct hax_vcpu_state *vcpu); int hax_vcpu_create(int id); int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907125; cv=none; d=zohomail.com; s=zohoarc; b=nvsEd0x2LSd3D1QB9fDPgKxrdEXd/C65BxzXRXAUbP4cfFHhpQSHIdGsQ5rw1fNtVvfG/t6OaAyC9M43kzvHLKAF+DYd0oMrmTXOjkiOwmUfQnaGXYZAHvnDsqLCpU1un1DrJO9QpFlInkNYeFyHqd/NlQtVQlz/voRx+bvAkKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907125; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=29AlYbIXVBIeOwrHqg3LZpvYsZ2xsGsqiqZLm2UcVxg=; b=Bbt4fahyTZSybyIxWblFnDoJwApRMeoN9DVjVEmWl47hQFVVpKVxfY/hh8G4bRcUYlu7nW153eCiEv1SmGPQ5eTc5UkZH6WWj5fWq22iPybQ3Db2qcjjYwBSZ1KX1QrdyKaApO4AFgxuZ/y2+whth/d8XbP4vS4Keb5HJHVgTNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190712564449.353858732217645; Thu, 11 Jun 2020 13:25:25 -0700 (PDT) Received: from localhost ([::1]:39270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTlM-0005N0-8d for importer@patchew.org; Thu, 11 Jun 2020 16:25:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9x-000130-Jy for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:45 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21617 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9v-0001Jo-MQ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-U950Cc47Mm2BJra5LfFzoA-1; Thu, 11 Jun 2020 15:45:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 102AC107ACCA; Thu, 11 Jun 2020 19:45:30 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DFD35C1B2; Thu, 11 Jun 2020 19:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904803; 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=29AlYbIXVBIeOwrHqg3LZpvYsZ2xsGsqiqZLm2UcVxg=; b=egwZe2cPIgIfg72fpIYq+TLpgoDnCDjuPiJ3Zp0GJMU0InKwp7/QMwpIP0RvO7X0rjiOf1 HyEdM3MLL/ymxqLbo/DYT0EBKrbKR6oR3DcVFxDSqyHQgG8Lr+lN3fgtKBIqey8uwPlkvG EZ/ZUR+co2Whc5kW6LvoHfHIHJXuVPs= X-MC-Unique: U950Cc47Mm2BJra5LfFzoA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 047/115] i386/kvm: fix a use-after-free when vcpu plug/unplug Date: Thu, 11 Jun 2020 15:43:41 -0400 Message-Id: <20200611194449.31468-48-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Igor Mammedov , Pan Nengyuan , Euler Robot Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Pan Nengyuan When we hotplug vcpus, cpu_update_state is added to vm_change_state_head in kvm_arch_init_vcpu(). But it forgot to delete in kvm_arch_destroy_vcpu()= after unplug. Then it will cause a use-after-free access. This patch delete it in kvm_arch_destroy_vcpu() to fix that. Reproducer: virsh setvcpus vm1 4 --live virsh setvcpus vm1 2 --live virsh suspend vm1 virsh resume vm1 The UAF stack: =3D=3Dqemu-system-x86_64=3D=3D28233=3D=3DERROR: AddressSanitizer: heap-use-= after-free on address 0x62e00002e798 at pc 0x5573c6917d9e bp 0x7fff07139e50= sp 0x7fff07139e40 WRITE of size 1 at 0x62e00002e798 thread T0 #0 0x5573c6917d9d in cpu_update_state /mnt/sdb/qemu/target/i386/kvm.c:7= 42 #1 0x5573c699121a in vm_state_notify /mnt/sdb/qemu/vl.c:1290 #2 0x5573c636287e in vm_prepare_start /mnt/sdb/qemu/cpus.c:2144 #3 0x5573c6362927 in vm_start /mnt/sdb/qemu/cpus.c:2150 #4 0x5573c71e8304 in qmp_cont /mnt/sdb/qemu/monitor/qmp-cmds.c:173 #5 0x5573c727cb1e in qmp_marshal_cont qapi/qapi-commands-misc.c:835 #6 0x5573c7694c7a in do_qmp_dispatch /mnt/sdb/qemu/qapi/qmp-dispatch.c:= 132 #7 0x5573c7694c7a in qmp_dispatch /mnt/sdb/qemu/qapi/qmp-dispatch.c:175 #8 0x5573c71d9110 in monitor_qmp_dispatch /mnt/sdb/qemu/monitor/qmp.c:1= 45 #9 0x5573c71dad4f in monitor_qmp_bh_dispatcher /mnt/sdb/qemu/monitor/qm= p.c:234 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200513132630.13412-1-pannengyuan@huawei.com> Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/kvm.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 00d1f4f013..37572bd437 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1634,6 +1634,7 @@ struct X86CPU { =20 CPUNegativeOffsetState neg; CPUX86State env; + VMChangeStateEntry *vmsentry; =20 uint64_t ucode_rev; =20 diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 95bbeb424b..ef2e0a81dd 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1741,7 +1741,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } } =20 - qemu_add_vm_change_state_handler(cpu_update_state, env); + cpu->vmsentry =3D qemu_add_vm_change_state_handler(cpu_update_state, e= nv); =20 c =3D cpuid_find_entry(&cpuid_data.cpuid, 1, 0); if (c) { @@ -1852,6 +1852,8 @@ int kvm_arch_destroy_vcpu(CPUState *cs) env->nested_state =3D NULL; } =20 + qemu_del_vm_change_state_handler(cpu->vmsentry); + return 0; } =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906430; cv=none; d=zohomail.com; s=zohoarc; b=c8gaWaAM6K5eV061XE6OaAByP3+f0bVNa0y3myM0GWzHj6yZ1PaJKt1AJRxtbeMNw5ceZ/2haPeEANK52bomj6r+CS+inHB3Pa9jVqWXmOu85G7qct9AESaDp66G+mgi1PAMInUOfO/y9UxKz0jIECAaktrrK/4Dp5aNY2e+ZeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906430; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4Mbj5vgjss3CvRpPXq7RdlTUMRKOXIk7ERJJk8CCfwI=; b=crGVFzG2nYLlA4Jc1z2Qx+8+aZQ+qeenARhzg5vSikca7FQeCxHSZhLYSSYIR1eLY7mjKL2VnnhHR9+L2xa9C7qMd+h1dg9IrWaeHWQxxQqMeBPWyHsd7CNy4SB4VcqMIVSbFnWZ0z5lqn+oAoQ55KABbWtRfEDtZW2hdOPgDug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906430979661.4780120631598; Thu, 11 Jun 2020 13:13:50 -0700 (PDT) Received: from localhost ([::1]:52132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTa9-0001VV-N0 for importer@patchew.org; Thu, 11 Jun 2020 16:13:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9Y-0000Ap-QB for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:20 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41476 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9W-0001FS-WE for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-6illYicoP4OvH4nl9KDMqA-1; Thu, 11 Jun 2020 15:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDE57107ACF3; Thu, 11 Jun 2020 19:45:30 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D1E45C1B2; Thu, 11 Jun 2020 19:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904778; 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=4Mbj5vgjss3CvRpPXq7RdlTUMRKOXIk7ERJJk8CCfwI=; b=ax4qgRZcff3poGzVeKIKqp3j5W6cCki1fV5nDu/MyI7Evf9/VXrPOJLbKw3BwfaSGt2ikb KfJ88HcwGqxvundhtj7Wlp67QCRvWq1XmpSDe/3cFMVc7yFDKxsawtljdxFWEuKuMi7sNa vCB4Mkg3xKXOr9TrnV2FgqSSmrz6yak= X-MC-Unique: 6illYicoP4OvH4nl9KDMqA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 048/115] megasas: use unsigned type for reply_queue_head and check index Date: Thu, 11 Jun 2020 15:43:42 -0400 Message-Id: <20200611194449.31468-49-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ren Ding , Alexander Bulekov , Prasad J Pandit , Hanqing Zhao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit A guest user may set 'reply_queue_head' field of MegasasState to a negative value. Later in 'megasas_lookup_frame' it is used to index into s->frames[] array. Use unsigned type to avoid OOB access issue. Also check that 'index' value stays within s->frames[] bounds through the while() loop in 'megasas_lookup_frame' to avoid OOB access. Reported-by: Ren Ding Reported-by: Hanqing Zhao Reported-by: Alexander Bulekov Signed-off-by: Prasad J Pandit Acked-by: Alexander Bulekov Message-Id: <20200513192540.1583887-2-ppandit@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index af18c88b65..6ce598cd69 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -112,7 +112,7 @@ typedef struct MegasasState { uint64_t reply_queue_pa; void *reply_queue; int reply_queue_len; - int reply_queue_head; + uint16_t reply_queue_head; int reply_queue_tail; uint64_t consumer_pa; uint64_t producer_pa; @@ -445,7 +445,7 @@ static MegasasCmd *megasas_lookup_frame(MegasasState *s, =20 index =3D s->reply_queue_head; =20 - while (num < s->fw_cmds) { + while (num < s->fw_cmds && index < MEGASAS_MAX_FRAMES) { if (s->frames[index].pa && s->frames[index].pa =3D=3D frame) { cmd =3D &s->frames[index]; break; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906771; cv=none; d=zohomail.com; s=zohoarc; b=YAqRp+nCMYACveY+S5m4phg9Gi9V9L+HMKxZbsb/NAk3OnLvWfu0cXKZgcURE5ghaOfmWyPyGjhcw7wopg3KvKxwA7SgwN0hYMKC+Fq1fB+7WmZG6Lqfvf/SnHbakiF60NahvAd/1jLPLG9Dft7y40nqgoGTQ1eb41M4su0S+QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906771; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1VzHEstmkcfBluh1Zt5NVAL7NC1s/peHLgv3pB7GyL0=; b=P6jchZyi4obpvYajeYUX7+1WL/Y5P06kkrl3eWjY5D9pCWBhxUcLPNFHrtBPY38lFTYPGP27dYj/0niUhEFpxJDhiINcnT3KxC//kzBqcV+uStlMBfWYrTOk6Fw4zhKaykI9Kkjf87MkOCvoLl8tZK+RFNOZ7nJ7eNgZ2owrtkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190677165485.46203873021955; Thu, 11 Jun 2020 13:19:31 -0700 (PDT) Received: from localhost ([::1]:48086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTfe-0003uC-BJ for importer@patchew.org; Thu, 11 Jun 2020 16:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8z-00081G-K6 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37128 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8v-00015j-WA for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-SZc5WDPIPN-lPKCxzbdYzw-1; Thu, 11 Jun 2020 15:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C6B2A0C01; Thu, 11 Jun 2020 19:45:31 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA8EE5C1B2; Thu, 11 Jun 2020 19:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904741; 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=1VzHEstmkcfBluh1Zt5NVAL7NC1s/peHLgv3pB7GyL0=; b=RVvE8dhhxbudZgN9uqhYAuED+l8Wqx6u9+Qzue4/RydPlV9IxfaBHzPCqcQPTdL5JDtg5I 5dAAwtrHQXmamk47ELPiv6fZAWa52bb0UmtVOuJuR5VTYCqMz4u+1+4b4RS88yKSwU8YUg 0R1XK4S5zPcVyquAAXDZ7qnl+TnpDuE= X-MC-Unique: SZc5WDPIPN-lPKCxzbdYzw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 049/115] megasas: avoid NULL pointer dereference Date: Thu, 11 Jun 2020 15:43:43 -0400 Message-Id: <20200611194449.31468-50-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov , Prasad J Pandit , Darren Kenny Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit While in megasas_handle_frame(), megasas_enqueue_frame() may set a NULL frame into MegasasCmd object for a given 'frame_addr' address. Add check to avoid a NULL pointer dereference issue. Reported-by: Alexander Bulekov Fixes: https://bugs.launchpad.net/qemu/+bug/1878259 Signed-off-by: Prasad J Pandit Acked-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-Id: <20200513192540.1583887-3-ppandit@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 6ce598cd69..b531d88a9b 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -504,7 +504,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *= s, cmd->pa =3D frame; /* Map all possible frames */ cmd->frame =3D pci_dma_map(pcid, frame, &frame_size_p, 0); - if (frame_size_p !=3D frame_size) { + if (!cmd->frame || frame_size_p !=3D frame_size) { trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame); if (cmd->frame) { megasas_unmap_frame(s, cmd); --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908738; cv=none; d=zohomail.com; s=zohoarc; b=l9MdLw6Ts6S1dawZshv/CWW1RXBe+32s1RTTcx1ANHYyPPMpTHTPy8OjfoI3tKrFKQkiDPuTm1QXw2NLhv6KVwcqQD69qiIFPAMxEB8bJDdH99XiWEbCLkHgd9dD3DrD3ktL3cSbfJEp1DeLqIEh0UVNVXVBKw51mrRseTX6P7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908738; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a73EkG8U8D9BCjCFB5TiIhzQ4MU/D3Nfp+b25PES2l0=; b=iAtpMwLja9epqKU90DOKvi2cXJUVKb+vy6QGVIHaWhfMCf7NdHYIszlUsFqPP8JbYLr5JUH870WVDJYYovog5AcWUchoX82RkTdc97MdExESTBSLT66P38FSWLeG1eGw2oc5lwan8wcCn+BVUY2NuvlBGbGXNvS7885nEs/3jlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908738603610.1246108664466; Thu, 11 Jun 2020 13:52:18 -0700 (PDT) Received: from localhost ([::1]:46274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUBN-0000MM-Ga for importer@patchew.org; Thu, 11 Jun 2020 16:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAF-0001Z4-14 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:03 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20552 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAD-0001Nl-3F for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-8lKXVV2-PXaMhC1e5HeTQg-1; Thu, 11 Jun 2020 15:45:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4FA0B8015CE; Thu, 11 Jun 2020 19:45:32 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D50BF8FF6A; Thu, 11 Jun 2020 19:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904820; 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=a73EkG8U8D9BCjCFB5TiIhzQ4MU/D3Nfp+b25PES2l0=; b=dqERvpkF9hxT7AtAZRjPtjbYyfvG1A8u8lYdmF2vG/NY0uSWFrtHbfO+HawQQ4EvirXTUz kx2VPxiWzcvwSSOEgYYyT+Fq74QIfnTeVr/brK8muCqvpjN9yj6zM6F7awcNWvLv16Ezxt GeyrOIx3y60I+Vlf96oGBdb5wBMcGh0= X-MC-Unique: 8lKXVV2-PXaMhC1e5HeTQg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 050/115] megasas: use unsigned type for positive numeric fields Date: Thu, 11 Jun 2020 15:43:44 -0400 Message-Id: <20200611194449.31468-51-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Darren Kenny , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit Use unsigned type for the MegasasState fields which hold positive numeric values. Signed-off-by: Prasad J Pandit Reviewed-by: Darren Kenny Message-Id: <20200513192540.1583887-4-ppandit@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index b531d88a9b..634af0bbb8 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -86,34 +86,34 @@ typedef struct MegasasState { MemoryRegion queue_io; uint32_t frame_hi; =20 - int fw_state; + uint32_t fw_state; uint32_t fw_sge; uint32_t fw_cmds; uint32_t flags; - int fw_luns; - int intr_mask; - int doorbell; - int busy; - int diag; - int adp_reset; + uint32_t fw_luns; + uint32_t intr_mask; + uint32_t doorbell; + uint32_t busy; + uint32_t diag; + uint32_t adp_reset; OnOffAuto msi; OnOffAuto msix; =20 MegasasCmd *event_cmd; - int event_locale; + uint16_t event_locale; int event_class; - int event_count; - int shutdown_event; - int boot_event; + uint32_t event_count; + uint32_t shutdown_event; + uint32_t boot_event; =20 uint64_t sas_addr; char *hba_serial; =20 uint64_t reply_queue_pa; void *reply_queue; - int reply_queue_len; + uint16_t reply_queue_len; uint16_t reply_queue_head; - int reply_queue_tail; + uint16_t reply_queue_tail; uint64_t consumer_pa; uint64_t producer_pa; =20 @@ -2259,9 +2259,9 @@ static const VMStateDescription vmstate_megasas_gen1 = =3D { VMSTATE_PCI_DEVICE(parent_obj, MegasasState), VMSTATE_MSIX(parent_obj, MegasasState), =20 - VMSTATE_INT32(fw_state, MegasasState), - VMSTATE_INT32(intr_mask, MegasasState), - VMSTATE_INT32(doorbell, MegasasState), + VMSTATE_UINT32(fw_state, MegasasState), + VMSTATE_UINT32(intr_mask, MegasasState), + VMSTATE_UINT32(doorbell, MegasasState), VMSTATE_UINT64(reply_queue_pa, MegasasState), VMSTATE_UINT64(consumer_pa, MegasasState), VMSTATE_UINT64(producer_pa, MegasasState), @@ -2278,9 +2278,9 @@ static const VMStateDescription vmstate_megasas_gen2 = =3D { VMSTATE_PCI_DEVICE(parent_obj, MegasasState), VMSTATE_MSIX(parent_obj, MegasasState), =20 - VMSTATE_INT32(fw_state, MegasasState), - VMSTATE_INT32(intr_mask, MegasasState), - VMSTATE_INT32(doorbell, MegasasState), + VMSTATE_UINT32(fw_state, MegasasState), + VMSTATE_UINT32(intr_mask, MegasasState), + VMSTATE_UINT32(doorbell, MegasasState), VMSTATE_UINT64(reply_queue_pa, MegasasState), VMSTATE_UINT64(consumer_pa, MegasasState), VMSTATE_UINT64(producer_pa, MegasasState), --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906415; cv=none; d=zohomail.com; s=zohoarc; b=gcal0utUceAG2YoiboruR+FRsJYDXj0VluYBWWtVEWaUmVLaMZgUnig7Zcu75EyjyqSaHjpgEGaM2xUVqRCu6sUeAc3WwS7WAxyz5haMk9Uh1vhB4SqVzz7Qe52vElXeBmPagvrqQEqcH+r22IbzAo4X2bBoiYOZu3QVKW1TMA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906415; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N/wjUl3m9r8YPv43a4ONQjZjOlKS4ioJdW6M+fE0u9c=; b=Lx+oJG3EZD1zUye7q6bK+9ZEaz45+l8ccKPb6rCD1JQTfgSw3fhOiKN7yx/eZVYmXxcJSPb9VeqBaICEhlZz5fU3Yhf6ZSEiI/pzCytTiK+fr23GMblEbOVyiiA4BPbtOKm4DnkPHX5vAP2iaAEOURNsUsvQqRlmMRFUD/u+2m4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906415384749.4322770889459; Thu, 11 Jun 2020 13:13:35 -0700 (PDT) Received: from localhost ([::1]:50956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTZu-00011X-0x for importer@patchew.org; Thu, 11 Jun 2020 16:13:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8w-0007vm-6I for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51368 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8r-00011i-1o for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-RvBDhcJTOM26uZFVRVuLfw-1; Thu, 11 Jun 2020 15:45:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F030F100A8E8; Thu, 11 Jun 2020 19:45:32 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76010707C6; Thu, 11 Jun 2020 19:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904736; 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=N/wjUl3m9r8YPv43a4ONQjZjOlKS4ioJdW6M+fE0u9c=; b=YwgtY0E98ouV9J526lj9yN5rlRCi7K7rkbv53glSHCuuNt/0BShk5xpdu5ZhXLmXGssPlp jPjAi/M3XutFw0EwbjXccRP+WaSOvawX4gE6w2N4CLxejwLeWQXWVmEwMMcT+VyiP231Cm 4gPHCoTLujQPonydUhUagVHTputl9Og= X-MC-Unique: RvBDhcJTOM26uZFVRVuLfw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 051/115] target/i386: implement special cases for fxtract Date: Thu, 11 Jun 2020 15:43:45 -0400 Message-Id: <20200611194449.31468-52-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Joseph Myers The implementation of the fxtract instruction treats all nonzero operands as normal numbers, so yielding incorrect results for invalid formats, infinities, NaNs and subnormal and pseudo-denormal operands. Implement appropriate handling of all those cases. Signed-off-by: Joseph Myers Acked-by: Alex Benn=C3=A9e Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 25 +++++- tests/tcg/i386/test-i386-fxtract.c | 120 +++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/i386/test-i386-fxtract.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index b34fa784eb..568bd3b359 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -767,10 +767,33 @@ void helper_fxtract(CPUX86State *env) &env->fp_status); fpush(env); ST0 =3D temp.d; + } else if (floatx80_invalid_encoding(ST0)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_default_nan(&env->fp_status); + fpush(env); + ST0 =3D ST1; + } else if (floatx80_is_any_nan(ST0)) { + if (floatx80_is_signaling_nan(ST0, &env->fp_status)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_silence_nan(ST0, &env->fp_status); + } + fpush(env); + ST0 =3D ST1; + } else if (floatx80_is_infinity(ST0)) { + fpush(env); + ST0 =3D ST1; + ST1 =3D floatx80_infinity; } else { int expdif; =20 - expdif =3D EXPD(temp) - EXPBIAS; + if (EXPD(temp) =3D=3D 0) { + int shift =3D clz64(temp.l.lower); + temp.l.lower <<=3D shift; + expdif =3D 1 - EXPBIAS - shift; + float_raise(float_flag_input_denormal, &env->fp_status); + } else { + expdif =3D EXPD(temp) - EXPBIAS; + } /* DP exponent bias */ ST0 =3D int32_to_floatx80(expdif, &env->fp_status); fpush(env); diff --git a/tests/tcg/i386/test-i386-fxtract.c b/tests/tcg/i386/test-i386-= fxtract.c new file mode 100644 index 0000000000..64fd93d333 --- /dev/null +++ b/tests/tcg/i386/test-i386-fxtract.c @@ -0,0 +1,120 @@ +/* Test fxtract instruction. */ + +#include +#include + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile union u ld_pseudo_m16382 =3D { .s =3D { UINT64_C(1) << 63, 0 } }; +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; +volatile union u ld_invalid_2 =3D { .s =3D { 0, 1234 } }; +volatile union u ld_invalid_3 =3D { .s =3D { 0, 0x7fff } }; +volatile union u ld_invalid_4 =3D { .s =3D { (UINT64_C(1) << 63) - 1, 0x7f= ff } }; + +volatile long double ld_sig, ld_exp; + +int isnan_ld(long double x) +{ + union u tmp =3D { .ld =3D x }; + return ((tmp.s.sign_exp & 0x7fff) =3D=3D 0x7fff && + (tmp.s.sig >> 63) !=3D 0 && + (tmp.s.sig << 1) !=3D 0); +} + +int issignaling_ld(long double x) +{ + union u tmp =3D { .ld =3D x }; + return isnan_ld(x) && (tmp.s.sig & UINT64_C(0x4000000000000000)) =3D= =3D 0; +} + +int main(void) +{ + int ret =3D 0; + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : "0" (= 2.5L)); + if (ld_sig !=3D 1.25L || ld_exp !=3D 1.0L) { + printf("FAIL: fxtract 2.5\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : "0" (= 0.0L)); + if (ld_sig !=3D 0.0L || __builtin_copysignl(1.0L, ld_sig) !=3D 1.0L || + ld_exp !=3D -__builtin_infl()) { + printf("FAIL: fxtract 0.0\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : "0" (= -0.0L)); + if (ld_sig !=3D -0.0L || __builtin_copysignl(1.0L, ld_sig) !=3D -1.0L = || + ld_exp !=3D -__builtin_infl()) { + printf("FAIL: fxtract -0.0\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (__builtin_infl())); + if (ld_sig !=3D __builtin_infl() || ld_exp !=3D __builtin_infl()) { + printf("FAIL: fxtract inf\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (-__builtin_infl())); + if (ld_sig !=3D -__builtin_infl() || ld_exp !=3D __builtin_infl()) { + printf("FAIL: fxtract -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (__builtin_nanl(""))); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract qnan\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (__builtin_nansl(""))); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract snan\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (0x1p-16445L)); + if (ld_sig !=3D 1.0L || ld_exp !=3D -16445.0L) { + printf("FAIL: fxtract subnormal\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (ld_pseudo_m16382.ld)); + if (ld_sig !=3D 1.0L || ld_exp !=3D -16382.0L) { + printf("FAIL: fxtract pseudo\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (ld_invalid_1.ld)); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract invalid 1\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (ld_invalid_2.ld)); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract invalid 2\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (ld_invalid_3.ld)); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract invalid 3\n"); + ret =3D 1; + } + __asm__ volatile ("fxtract" : "=3Dt" (ld_sig), "=3Du" (ld_exp) : + "0" (ld_invalid_4.ld)); + if (!isnan_ld(ld_sig) || issignaling_ld(ld_sig) || + !isnan_ld(ld_exp) || issignaling_ld(ld_exp)) { + printf("FAIL: fxtract invalid 4\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906588; cv=none; d=zohomail.com; s=zohoarc; b=LmUzXAczBgZ0DwPnM8OeOnEVsB6IHyyR8us8dRIUcfkOeespZsvJqHLmg7Fp2Fu0XsCJhwKZPAPqsD9bylP0JHKzKYSb0/2V27y2dewezYg9fuqZ4TtzVlIXupH7Y8zucviIILIGz96s0n0AdebjOTZp0oKIHwdigon52miXzgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906588; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9MiZTuB1jn4OQN9DsLVSeuNz7XUvR6qH6PEUWfjPKZw=; b=NBGZo2ieHPZPO+U/56yEFd7YNpzEbEHtmKDkGZVEX/3DnDb6/CaMty55S8VCnrGe8CbsJhbRkqGPykU5GqhBasNkxqoUtyfVEfjOAU2w8IvBrb9VEiVj1pkHmWkvSWpTQ2iN9TOZKP9GW/OtMV2ith+Y9KZ4h8Hq3IlxBTbfAW4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906588875528.6550332039503; Thu, 11 Jun 2020 13:16:28 -0700 (PDT) Received: from localhost ([::1]:34358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTch-0005sd-K9 for importer@patchew.org; Thu, 11 Jun 2020 16:16:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8v-0007uV-3x for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36463 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8s-00011r-1L for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-YsuNxs3hM4e08-P8UdY26g-1; Thu, 11 Jun 2020 15:45:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0153A0C00; Thu, 11 Jun 2020 19:45:33 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 231B8707C6; Thu, 11 Jun 2020 19:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904737; 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=9MiZTuB1jn4OQN9DsLVSeuNz7XUvR6qH6PEUWfjPKZw=; b=TObTXdofZ5MKpmiRkQO9PkP3xszFjYMhP6HDIb4f9OVYz6JT1ntj3PmOxdLK7m55+JxIJR OVQxXv/g9wwXmENZNVr3pJO3jlWhKaRO5gDGHScAzidT6dmi8V+sSuayKedvDh3evLoR9S GJv4+B16HO+JUcXDq5D+MyvUpLWTh70= X-MC-Unique: YsuNxs3hM4e08-P8UdY26g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 052/115] target/i386: fix fscale handling of signaling NaN Date: Thu, 11 Jun 2020 15:43:46 -0400 Message-Id: <20200611194449.31468-53-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The implementation of the fscale instruction returns a NaN exponent unchanged. Fix it to return a quiet NaN when the provided exponent is a signaling NaN. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 4 ++++ tests/tcg/i386/test-i386-fscale.c | 37 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/tcg/i386/test-i386-fscale.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 568bd3b359..0671de6952 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -970,6 +970,10 @@ void helper_fscale(CPUX86State *env) { if (floatx80_is_any_nan(ST1)) { ST0 =3D ST1; + if (floatx80_is_signaling_nan(ST0, &env->fp_status)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_silence_nan(ST0, &env->fp_status); + } } else { int n =3D floatx80_to_int32_round_to_zero(ST1, &env->fp_status); ST0 =3D floatx80_scalbn(ST0, n, &env->fp_status); diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-f= scale.c new file mode 100644 index 0000000000..aecac5125f --- /dev/null +++ b/tests/tcg/i386/test-i386-fscale.c @@ -0,0 +1,37 @@ +/* Test fscale instruction. */ + +#include +#include + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile long double ld_res; + +int isnan_ld(long double x) +{ + union u tmp =3D { .ld =3D x }; + return ((tmp.s.sign_exp & 0x7fff) =3D=3D 0x7fff && + (tmp.s.sig >> 63) !=3D 0 && + (tmp.s.sig << 1) !=3D 0); +} + +int issignaling_ld(long double x) +{ + union u tmp =3D { .ld =3D x }; + return isnan_ld(x) && (tmp.s.sig & UINT64_C(0x4000000000000000)) =3D= =3D 0; +} + +int main(void) +{ + int ret =3D 0; + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (2.5L), "u" (__builtin_nansl(""))); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale snan\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906539; cv=none; d=zohomail.com; s=zohoarc; b=Wj/D66Qg3Tjk0OKK2Exr4xCl4mqbrQm2I23C6MhUJVrVntGl2Zudl0UUay/Wj5KtNwYwLRwrA5G6QmNA7uDjGJKhqIizxadOUx0BspoQDSqRsK0OqE1NqE2h0o0ky/RRjUbdBzZIqezC+4Veq/jF7cFkrKPYkvwtapm31ih7XlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7pqCnSjTR2PzSL+AfGbFKdpToycd8SKN9cXtHQcKSko=; b=EZVw3FYJ4ytBYAw34yA97FRnc2Rr0BOl24bSH/xnX1Ld5qlwcfMrGndWr8GvAEHWnGzM6sH6abN4DyxYvpfQVibpKN7MP7L1EqRPDoCjoLgfrkUdrs7WT9IoVmNYybCaUQ0z85WIJFve1/eBIaS0n1k1ziGzY06/gaokWHXwfqo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906539860914.2451593702453; Thu, 11 Jun 2020 13:15:39 -0700 (PDT) Received: from localhost ([::1]:59386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTbu-0004SQ-Gd for importer@patchew.org; Thu, 11 Jun 2020 16:15:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8y-0007ys-3P for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:44 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:41655 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8s-000123-Dq for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-136-cUdRcWTjPWyjC3MWTIT2Kg-1; Thu, 11 Jun 2020 15:45:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BFAE1800D41; Thu, 11 Jun 2020 19:45:34 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12AD38FF88; Thu, 11 Jun 2020 19:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904737; 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=7pqCnSjTR2PzSL+AfGbFKdpToycd8SKN9cXtHQcKSko=; b=U/akjp+YdMq2I6G/7AR9okt3hteO/0A2aZe6hpSz5HMuoC9qP5fF9ALZFBHRdc6CzL+ld5 3ctO1Stx7fDzI93piTzvktyhtOnCoPjibVpu1PyyYqsO4O4/iS5yPCRWueFoaowFzpMZEb 31LNWLR2DPcGaiXRQoRdhWeo9ZcKCJg= X-MC-Unique: cUdRcWTjPWyjC3MWTIT2Kg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 053/115] target/i386: fix fscale handling of invalid exponent encodings Date: Thu, 11 Jun 2020 15:43:47 -0400 Message-Id: <20200611194449.31468-54-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fscale implementation does not check for invalid encodings in the exponent operand, thus treating them like INT_MIN (the value returned for invalid encodings by floatx80_to_int32_round_to_zero). Fix it to treat them similarly to signaling NaN exponents, thus generating a quiet NaN result. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 5 ++++- tests/tcg/i386/test-i386-fscale.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 0671de6952..10ff90370e 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -968,7 +968,10 @@ void helper_frndint(CPUX86State *env) =20 void helper_fscale(CPUX86State *env) { - if (floatx80_is_any_nan(ST1)) { + if (floatx80_invalid_encoding(ST1)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_default_nan(&env->fp_status); + } else if (floatx80_is_any_nan(ST1)) { ST0 =3D ST1; if (floatx80_is_signaling_nan(ST0, &env->fp_status)) { float_raise(float_flag_invalid, &env->fp_status); diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-f= scale.c index aecac5125f..b65a055d0a 100644 --- a/tests/tcg/i386/test-i386-fscale.c +++ b/tests/tcg/i386/test-i386-fscale.c @@ -8,6 +8,11 @@ union u { long double ld; }; =20 +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; +volatile union u ld_invalid_2 =3D { .s =3D { 0, 1234 } }; +volatile union u ld_invalid_3 =3D { .s =3D { 0, 0x7fff } }; +volatile union u ld_invalid_4 =3D { .s =3D { (UINT64_C(1) << 63) - 1, 0x7f= ff } }; + volatile long double ld_res; =20 int isnan_ld(long double x) @@ -33,5 +38,29 @@ int main(void) printf("FAIL: fscale snan\n"); ret =3D 1; } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (2.5L), "u" (ld_invalid_1.ld)); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale invalid 1\n"); + ret =3D 1; + } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (2.5L), "u" (ld_invalid_2.ld)); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale invalid 2\n"); + ret =3D 1; + } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (2.5L), "u" (ld_invalid_3.ld)); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale invalid 3\n"); + ret =3D 1; + } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (2.5L), "u" (ld_invalid_4.ld)); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale invalid 4\n"); + ret =3D 1; + } return ret; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906973; cv=none; d=zohomail.com; s=zohoarc; b=Gt5AITBwru/2a1WBf06CO5bYz6LJzSQyFTeDb0GZ7DLiRjBrXjcUFYNNd4HjW5aNFrTQF6tlIr6pe71rb+7JpZgz3tbUP2Ei4J0Sf+9aNG1rEj8lp0fRWlLaWLYZ7w5GY4eVUN2yZxe63SVL/6Wa7UyOkcNjG9qSAgSaPZ78MZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6DTxtOc5LdYdP17d4UDiZN2OUZYIKMNt5E0uvZNLm+g=; b=AGUw1AsYSvJAEadwd/98Gxh0uiG46NFZHt+TZdv1khOA06LbN/zyPm/fZtg0DUQ9KuOTSe2kraNt5DWs7dRbtWEyvwTpGCZD5Hv8v9S6G5wvnBN2cRgQvP8STENxLXlnf109+PzsKMSMvXUWXzMK55D2T1F1FuWDcQfoQv5OdGE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906973937552.0988325480664; Thu, 11 Jun 2020 13:22:53 -0700 (PDT) Received: from localhost ([::1]:59956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTiu-0001L6-LR for importer@patchew.org; Thu, 11 Jun 2020 16:22:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT90-00082M-Bu for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:46 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50740 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8x-00016y-Fc for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-IYNd9nSgOUatmNfMtw6ZlA-1; Thu, 11 Jun 2020 15:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0221419057BF; Thu, 11 Jun 2020 19:45:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 920938FF7E; Thu, 11 Jun 2020 19:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904742; 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=6DTxtOc5LdYdP17d4UDiZN2OUZYIKMNt5E0uvZNLm+g=; b=godjkGweT2sWc3ak0rBpVyK0QBtdgJK22UByJXTn34oo6XmuImJ4oNAF8tzcq+AkWAJI56 LVXRqOhTnDQz/k+9MNTN31tjohZCRIw9oSaBaib4vL74nGoKmneZXEFIneDlQ9nv/l/nct tKTp91ve1+YKNckcd9duBCWc/NyOMoo= X-MC-Unique: IYNd9nSgOUatmNfMtw6ZlA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 054/115] target/i386: fix fscale handling of infinite exponents Date: Thu, 11 Jun 2020 15:43:48 -0400 Message-Id: <20200611194449.31468-55-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fscale implementation passes infinite exponents through to generic code that rounds the exponent to a 32-bit integer before using floatx80_scalbn. In round-to-nearest mode, and ignoring exceptions, this works in many cases. But it fails to handle the special cases of scaling 0 by a +Inf exponent or an infinity by a -Inf exponent, which should produce a NaN, and because it produces an inexact result for finite nonzero numbers being scaled, the result is sometimes incorrect in other rounding modes. Add appropriate handling of infinite exponents to produce a NaN or an appropriately signed exact zero or infinity as a result. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 22 ++++++++++++++++++++++ tests/tcg/i386/test-i386-fscale.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 10ff90370e..72d1e77eb0 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -977,6 +977,28 @@ void helper_fscale(CPUX86State *env) float_raise(float_flag_invalid, &env->fp_status); ST0 =3D floatx80_silence_nan(ST0, &env->fp_status); } + } else if (floatx80_is_infinity(ST1) && + !floatx80_invalid_encoding(ST0) && + !floatx80_is_any_nan(ST0)) { + if (floatx80_is_neg(ST1)) { + if (floatx80_is_infinity(ST0)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_default_nan(&env->fp_status); + } else { + ST0 =3D (floatx80_is_neg(ST0) ? + floatx80_chs(floatx80_zero) : + floatx80_zero); + } + } else { + if (floatx80_is_zero(ST0)) { + float_raise(float_flag_invalid, &env->fp_status); + ST0 =3D floatx80_default_nan(&env->fp_status); + } else { + ST0 =3D (floatx80_is_neg(ST0) ? + floatx80_chs(floatx80_infinity) : + floatx80_infinity); + } + } } else { int n =3D floatx80_to_int32_round_to_zero(ST1, &env->fp_status); ST0 =3D floatx80_scalbn(ST0, n, &env->fp_status); diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-f= scale.c index b65a055d0a..b953e7c563 100644 --- a/tests/tcg/i386/test-i386-fscale.c +++ b/tests/tcg/i386/test-i386-fscale.c @@ -31,6 +31,7 @@ int issignaling_ld(long double x) =20 int main(void) { + short cw; int ret =3D 0; __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (2.5L), "u" (__builtin_nansl(""))); @@ -62,5 +63,33 @@ int main(void) printf("FAIL: fscale invalid 4\n"); ret =3D 1; } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (0.0L), "u" (__builtin_infl())); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale 0 up inf\n"); + ret =3D 1; + } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (__builtin_infl()), "u" (-__builtin_infl())); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale inf down inf\n"); + ret =3D 1; + } + /* Set round-downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (1.0L), "u" (__builtin_infl())); + if (ld_res !=3D __builtin_infl()) { + printf("FAIL: fscale finite up inf\n"); + ret =3D 1; + } + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (-1.0L), "u" (-__builtin_infl())); + if (ld_res !=3D -0.0L || __builtin_copysignl(1.0L, ld_res) !=3D -1.0L)= { + printf("FAIL: fscale finite down inf\n"); + ret =3D 1; + } return ret; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906398; cv=none; d=zohomail.com; s=zohoarc; b=CFGACQiZTZcufiojVOAwAO+lH5buRRS6LwSbUReaGIPGrsaAswbzMcpSXvHUvU5ttgrslrUS6LpqLWG27WFeFuOpFLxL/GcG40JHVdemRLAKXyIf3e5jlVKF3tzBSqTR5reW2dtKZBkr5kolTH+p7o53PfDbsTThp209hJMwbqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906398; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UDBHQtVitR2UF3gM0easaFDJXNK3KOw8227wlXl8uXk=; b=avJlzmvmRFUea9dk3fQ9A8LRINRLjJ7UBAylD64RSQdu4LUWmHBIwbR5lGuVs0FjjG1WUltBu9AfYOBnnGmPfFL0TX1IEyLHmLKKnhCvSqvhUqMnnPCrlRfB5RaFw3jPuBwE7BnQZvdgIWbBQpEo7quu9+4ZyuDw6PyAqjmGy0g= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919063986691011.8493331650463; Thu, 11 Jun 2020 13:13:18 -0700 (PDT) Received: from localhost ([::1]:49418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTZd-0000Op-A0 for importer@patchew.org; Thu, 11 Jun 2020 16:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8x-0007xb-7M for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48332 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8t-00012O-Mp for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-Chn9K9sdN4Cp-6v131tnIw-1; Thu, 11 Jun 2020 15:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CB078064DD; Thu, 11 Jun 2020 19:45:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2053997B12; Thu, 11 Jun 2020 19:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904738; 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=UDBHQtVitR2UF3gM0easaFDJXNK3KOw8227wlXl8uXk=; b=gGlsxl5U1NMMBvZiOpZ8qAhGx19aSQWwmAYZNwsVxHJmb+SsUkCCS/kaiUtOONKl/dY0SI OnqrfUJr35WT53kDbgJtutb2oOklBcageSX8U9VDPFxa/qK7Rhgxv6PA79p9yaVlaaF6Zt wa2y/G5BsN+ObJTUxUG3i+dQajGquuA= X-MC-Unique: Chn9K9sdN4Cp-6v131tnIw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 055/115] target/i386: fix fscale handling of rounding precision Date: Thu, 11 Jun 2020 15:43:49 -0400 Message-Id: <20200611194449.31468-56-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fscale implementation uses floatx80_scalbn for the final scaling operation. floatx80_scalbn ends up rounding the result using the dynamic rounding precision configured for the FPU. But only a limited set of x87 floating-point instructions are supposed to respect the dynamic rounding precision, and fscale is not in that set. Fix the implementation to save and restore the rounding precision around the call to floatx80_scalbn. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 3 +++ tests/tcg/i386/test-i386-fscale.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 72d1e77eb0..4d14c1ca24 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -1001,7 +1001,10 @@ void helper_fscale(CPUX86State *env) } } else { int n =3D floatx80_to_int32_round_to_zero(ST1, &env->fp_status); + signed char save =3D env->fp_status.floatx80_rounding_precision; + env->fp_status.floatx80_rounding_precision =3D 80; ST0 =3D floatx80_scalbn(ST0, n, &env->fp_status); + env->fp_status.floatx80_rounding_precision =3D save; } } =20 diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-f= scale.c index b953e7c563..d23b3cfeec 100644 --- a/tests/tcg/i386/test-i386-fscale.c +++ b/tests/tcg/i386/test-i386-fscale.c @@ -8,6 +8,8 @@ union u { long double ld; }; =20 +volatile long double ld_third =3D 1.0L / 3.0L; +volatile long double ld_four_thirds =3D 4.0L / 3.0L; volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; volatile union u ld_invalid_2 =3D { .s =3D { 0, 1234 } }; volatile union u ld_invalid_3 =3D { .s =3D { 0, 0x7fff } }; @@ -91,5 +93,16 @@ int main(void) printf("FAIL: fscale finite down inf\n"); ret =3D 1; } + /* Set round-to-nearest with single-precision rounding. */ + cw =3D cw & ~0xf00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (ld_third), "u" (2.0L)); + cw =3D cw | 0x300; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + if (ld_res !=3D ld_four_thirds) { + printf("FAIL: fscale single-precision\n"); + ret =3D 1; + } return ret; } --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906708; cv=none; d=zohomail.com; s=zohoarc; b=ccYYu3VSjc0ok7xCyfXDepLbZyf/2MqLFZHY7GaCgBqudtWORQzMs/IOeNhtxMTTDmL43t9E4pbh5HosmRHNGBr/GrEMtT9H9VF55zSytVxTDN62KJv99HTHjOGI7d2mmgAc2rogomPeNHPpRNnjK5erBCaF2puaf6laX3hMxbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906708; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=brEVr7KtuKLlpe5+wUf9WnJ4DGKm96Q7guN6CwOpo9A=; b=hmN8CnaPvVVLcX0e8rxaKiU2jZ8eAigr4+IAreQM3fRQhBIuXEjrLGhhln+p1yvf9RfZ7DDAcf0LoOhrcu8OS3qjFkI+0kUw9dRr2l9wHpuoK2gtnUye20yde0LG0RbQnWYCYzV4IQV+JWvVrb2bpR6r25HsqGf1nu3GCTppYoU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190670856850.65203450785282; Thu, 11 Jun 2020 13:18:28 -0700 (PDT) Received: from localhost ([::1]:42850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTec-0001jY-Ui for importer@patchew.org; Thu, 11 Jun 2020 16:18:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8x-0007xn-Ds for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34500 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8u-000143-PY for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-AnpL-BUNMdyHwsxloCtnug-1; Thu, 11 Jun 2020 15:45:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 214A5801503; Thu, 11 Jun 2020 19:45:36 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A354A8FF91; Thu, 11 Jun 2020 19:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904740; 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=brEVr7KtuKLlpe5+wUf9WnJ4DGKm96Q7guN6CwOpo9A=; b=DllIdsqWIH1VeCR/aHLdRY8fGZc+7XuMLUqNmMWx386Bs1zmWq/981+lqFqXUhS1Ry8fE3 r030SL79L8TrttX9zJlJDpMSlGAJ90QdFIeydhk6Oto5FwaXR145YuokMch/euR94bXVaq UJu4agPp8Q8AnGzWhMh7ZFg5u8Qfgic= X-MC-Unique: AnpL-BUNMdyHwsxloCtnug-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 056/115] exec: Let address_space_read/write_cached() propagate MemTxResult Date: Thu, 11 Jun 2020 15:43:50 -0400 Message-Id: <20200611194449.31468-57-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Both address_space_read_cached_slow() and address_space_write_cached_slow() return a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- exec.c | 16 ++++++++-------- include/exec/memory.h | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/exec.c b/exec.c index be4be2df3a..0e197e53c2 100644 --- a/exec.c +++ b/exec.c @@ -3718,7 +3718,7 @@ static inline MemoryRegion *address_space_translate_c= ached( /* Called from RCU critical section. address_space_read_cached uses this * out of line function when the target is an MMIO or IOMMU region. */ -void +MemTxResult address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, void *buf, hwaddr len) { @@ -3728,15 +3728,15 @@ address_space_read_cached_slow(MemoryRegionCache *c= ache, hwaddr addr, l =3D len; mr =3D address_space_translate_cached(cache, addr, &addr1, &l, false, MEMTXATTRS_UNSPECIFIED); - flatview_read_continue(cache->fv, - addr, MEMTXATTRS_UNSPECIFIED, buf, len, - addr1, l, mr); + return flatview_read_continue(cache->fv, + addr, MEMTXATTRS_UNSPECIFIED, buf, len, + addr1, l, mr); } =20 /* Called from RCU critical section. address_space_write_cached uses this * out of line function when the target is an MMIO or IOMMU region. */ -void +MemTxResult address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, const void *buf, hwaddr len) { @@ -3746,9 +3746,9 @@ address_space_write_cached_slow(MemoryRegionCache *ca= che, hwaddr addr, l =3D len; mr =3D address_space_translate_cached(cache, addr, &addr1, &l, true, MEMTXATTRS_UNSPECIFIED); - flatview_write_continue(cache->fv, - addr, MEMTXATTRS_UNSPECIFIED, buf, len, - addr1, l, mr); + return flatview_write_continue(cache->fv, + addr, MEMTXATTRS_UNSPECIFIED, buf, len, + addr1, l, mr); } =20 #define ARG1_DECL MemoryRegionCache *cache diff --git a/include/exec/memory.h b/include/exec/memory.h index 3e00cdbbfa..48df5abe13 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2354,10 +2354,11 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_add= r_t addr); =20 /* Internal functions, part of the implementation of address_space_read_ca= ched * and address_space_write_cached. */ -void address_space_read_cached_slow(MemoryRegionCache *cache, - hwaddr addr, void *buf, hwaddr len); -void address_space_write_cached_slow(MemoryRegionCache *cache, - hwaddr addr, const void *buf, hwaddr = len); +MemTxResult address_space_read_cached_slow(MemoryRegionCache *cache, + hwaddr addr, void *buf, hwaddr = len); +MemTxResult address_space_write_cached_slow(MemoryRegionCache *cache, + hwaddr addr, const void *buf, + hwaddr len); =20 static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) { @@ -2422,15 +2423,16 @@ MemTxResult address_space_read(AddressSpace *as, hw= addr addr, * @buf: buffer with the data transferred * @len: length of the data transferred */ -static inline void +static inline MemTxResult address_space_read_cached(MemoryRegionCache *cache, hwaddr addr, void *buf, hwaddr len) { assert(addr < cache->len && len <=3D cache->len - addr); if (likely(cache->ptr)) { memcpy(buf, cache->ptr + addr, len); + return MEMTX_OK; } else { - address_space_read_cached_slow(cache, addr, buf, len); + return address_space_read_cached_slow(cache, addr, buf, len); } } =20 @@ -2442,15 +2444,16 @@ address_space_read_cached(MemoryRegionCache *cache,= hwaddr addr, * @buf: buffer with the data transferred * @len: length of the data transferred */ -static inline void +static inline MemTxResult address_space_write_cached(MemoryRegionCache *cache, hwaddr addr, const void *buf, hwaddr len) { assert(addr < cache->len && len <=3D cache->len - addr); if (likely(cache->ptr)) { memcpy(cache->ptr + addr, buf, len); + return MEMTX_OK; } else { - address_space_write_cached_slow(cache, addr, buf, len); + return address_space_write_cached_slow(cache, addr, buf, len); } } =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907551; cv=none; d=zohomail.com; s=zohoarc; b=asg1bmekWI0UarlHn6ZaWwJJddPwvg8QLe78z8sIk6Nb43SkQdZg9VRseABX99vA7a87t6Iis6vSdvNofXjYkkDkR/uhbhpmO5WX53CYJXh398ONCSxeq2XCMGXeSsETsgTnARk9RDmOu844I+3/EGhLq4NeLUATtlCt9Zl2w+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907551; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Gb5f4ZV3aI2a6P7aJxN28ce8kll/n1k7O4VqaZKICc=; b=FQaQYTk9S0n5ueEVQ3vO7DeC1RsPQHAXifSol6o2u6xem+ETuxJ1qZaMO+QZklIlwYx4ZwMiZC6/W9hBnidqBme82RiM6dtuZ7xyGqS1vYEEJdlHAXMLPFCvdAUf9yq9jTcMw0sRtxvkV/ZES2p+fkUOhiXgOO5MqHa6k911uL0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907550983818.2661311109358; Thu, 11 Jun 2020 13:32:30 -0700 (PDT) Received: from localhost ([::1]:34294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTsD-00078s-Fq for importer@patchew.org; Thu, 11 Jun 2020 16:32:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9p-0000j8-8y for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59027 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9n-0001JJ-7i for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-xg4uoLfMN2-bqW3D0h2ByQ-1; Thu, 11 Jun 2020 15:45:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A104DEC1AE; Thu, 11 Jun 2020 19:45:36 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 484CB8FF96; Thu, 11 Jun 2020 19:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904794; 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=6Gb5f4ZV3aI2a6P7aJxN28ce8kll/n1k7O4VqaZKICc=; b=AIhJADPrnVm2vZNEj9pWc2o03KkvKIjrZChe65SVvtPb0zLYFaEcCOr09V5bHbyVK7Uu1Q wb/cz1MOWKnmnB7qjgi8TtalOse4zBpNSEx0BuobrLjIz4NsjhsePY9NfUmSMRDwjy7NUX 0d+vBzUP56c8YraebLGICejAhH9zgz0= X-MC-Unique: xg4uoLfMN2-bqW3D0h2ByQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 057/115] exec: Propagate cpu_memory_rw_debug() error Date: Thu, 11 Jun 2020 15:43:51 -0400 Message-Id: <20200611194449.31468-58-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Do not ignore the MemTxResult error type returned by the address_space_rw() API. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- exec.c | 12 ++++++++---- include/exec/cpu-all.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index 0e197e53c2..9cbde85d8c 100644 --- a/exec.c +++ b/exec.c @@ -3771,6 +3771,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong a= ddr, while (len > 0) { int asidx; MemTxAttrs attrs; + MemTxResult res; =20 page =3D addr & TARGET_PAGE_MASK; phys_addr =3D cpu_get_phys_page_attrs_debug(cpu, page, &attrs); @@ -3783,11 +3784,14 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong= addr, l =3D len; phys_addr +=3D (addr & ~TARGET_PAGE_MASK); if (is_write) { - address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr, - attrs, buf, l); + res =3D address_space_write_rom(cpu->cpu_ases[asidx].as, phys_= addr, + attrs, buf, l); } else { - address_space_read(cpu->cpu_ases[asidx].as, phys_addr, attrs, = buf, - l); + res =3D address_space_read(cpu->cpu_ases[asidx].as, phys_addr, + attrs, buf, l); + } + if (res !=3D MEMTX_OK) { + return -1; } len -=3D l; buf +=3D l; diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d14374bdd4..fb4e8a8e29 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -413,6 +413,7 @@ void dump_exec_info(void); void dump_opcount_info(void); #endif /* !CONFIG_USER_ONLY */ =20 +/* Returns: 0 on success, -1 on error */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, void *ptr, target_ulong len, bool is_write); =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908315; cv=none; d=zohomail.com; s=zohoarc; b=Vv6s9OnPr9x2qpTSNCXE5Si8/EfJZ1ZvCwjH+QeyiWwpow8KFlLgq9aliSS6VISuPh7iUgJcR562FoPxWHE078zniZ2R89rxpAbv6//rgfGcbPzUI/Oaq+2Eo6T6scVkemF9aaq6BS1RYoyqqfjFTDDK3KuSJFDQvMDUSgRwoJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908315; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tDOSBX+I1rycg2KqbZ9V3sM7gy5Up2HI9ibUsGnKUzQ=; b=YdRQ0U6EJzg6/w3zyPK68ImEL/81ZNBpot+cRTmNOOv7g5GgKIl9qIyiqbPq4VjHltRzYcZ5YS/5CdojF+5Oq1xTsAOqZbdoFETpCCoDpqnmGl/3Xh5LwtnFcFYJ6tdls6sefAwwYSCo4lTHyu/2gmLs5308BiyV6rQfk+OTDSM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919083152591013.8427622080497; Thu, 11 Jun 2020 13:45:15 -0700 (PDT) Received: from localhost ([::1]:49666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU4X-0004Ai-MV for importer@patchew.org; Thu, 11 Jun 2020 16:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAS-00020h-SG for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:16 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24869 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAN-0001QE-4u for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-tD5-rnoaMDK9bfPik4eNJQ-1; Thu, 11 Jun 2020 15:45:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D0C88015CE; Thu, 11 Jun 2020 19:45:37 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7BD58FF91; Thu, 11 Jun 2020 19:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904830; 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=tDOSBX+I1rycg2KqbZ9V3sM7gy5Up2HI9ibUsGnKUzQ=; b=DBxdT668AeNtG5BKARUN0T6hEgzpYILtN1MLVpF3QSJ9M3rOsdm2WEqJLtutVpA9kNqJ95 Q8wmdcnoMXxeDhNlbLxH50BORuQmcdp9KTFwQ2ywE7E657lDGxsucWZJWw/LBBzqlloF7X SWmrHPPA+Pr6IzLtsOfKLTmOPCju+uw= X-MC-Unique: tD5-rnoaMDK9bfPik4eNJQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 058/115] disas: Let disas::read_memory() handler return EIO on error Date: Thu, 11 Jun 2020 15:43:52 -0400 Message-Id: <20200611194449.31468-59-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Both cpu_memory_rw_debug() and address_space_read() return an error on failed transaction. Check the returned value, and return EIO in case of error. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- disas.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/disas.c b/disas.c index 45285d3f63..c1397d3933 100644 --- a/disas.c +++ b/disas.c @@ -39,9 +39,11 @@ target_read_memory (bfd_vma memaddr, struct disassemble_info *info) { CPUDebug *s =3D container_of(info, CPUDebug, info); + int r; =20 - cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0); - return 0; + r =3D cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0); + + return r ? EIO : 0; } =20 /* Print an error message. We can assume that this is in response to @@ -718,10 +720,11 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myadd= r, int length, struct disassemble_info *info) { CPUDebug *s =3D container_of(info, CPUDebug, info); + MemTxResult res; =20 - address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, - myaddr, length); - return 0; + res =3D address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, + myaddr, length); + return res =3D=3D MEMTX_OK ? 0 : EIO; } =20 /* Disassembler for the monitor. */ --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906839; cv=none; d=zohomail.com; s=zohoarc; b=X68RtYBQYU0rQUCqo1UnIu7BeeVOXqbLqdjhoLq8mhVwJD+zBjBQcjvvbvQRxzRlZQy2d6x3r6UwI/T/TDCJQ/t7tdLV7SooQHn/QY1ziJoZe3QAqjEcTXWgCtxLWgF0CFItQKVGL6E9TTkWQqfSD02n305sTyIGjGN7ZRhzdPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906839; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s3IqJsgAL2cFBvkObBba9SfjTIZIJjajSNTBAb42Esw=; b=oK66fTh0OCSSx3kD7RTFuvLg/zrDUccEtZFYStOja9gufviivjfc1cSzA17fUO9LUUSurH0RguS2h/sxxTRTrvqzZe71aYO0ysgv7JL1zevmxjS1qDJ1ZQTbxLjZZG2oMGXKqHjrQaXNqv/gKjMXF4XqkNFTq1fmseFhZ7DHrpY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190683993579.824101253849; Thu, 11 Jun 2020 13:20:39 -0700 (PDT) Received: from localhost ([::1]:51458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTgk-0005Pi-IQ for importer@patchew.org; Thu, 11 Jun 2020 16:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT8y-0007zf-Np for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27764 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8v-00015h-VN for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-9MbTbZw9NF-wPohVNG1cTA-1; Thu, 11 Jun 2020 15:45:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05B558797F6; Thu, 11 Jun 2020 19:45:38 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 536648FF91; Thu, 11 Jun 2020 19:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904741; 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=s3IqJsgAL2cFBvkObBba9SfjTIZIJjajSNTBAb42Esw=; b=Nn1SCwbuO9kYAF5UhUCqnzf6jcYc0giG68yVSLIObEU4mmtf1VUdrkolMqsqRdjJ7jw5Fz hxk//9XFG2wdqo7oagLZzY4Y4BZ3b85tvi492O5T1zQ9fs6rGtT9GdBr2Yvl7mSyZVg0DH ekPB+wpIubM85vjFrgqP1szW3KAWzLY= X-MC-Unique: 9MbTbZw9NF-wPohVNG1cTA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 059/115] hw/elf_ops: Do not ignore write failures when loading ELF Date: Thu, 11 Jun 2020 15:43:53 -0400 Message-Id: <20200611194449.31468-60-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Do not ignore the MemTxResult error type returned by address_space_write(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella Signed-off-by: Paolo Bonzini --- include/hw/elf_ops.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 398a4a2c85..6fdff3dced 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -553,9 +553,14 @@ static int glue(load_elf, SZ)(const char *name, int fd, rom_add_elf_program(label, mapped_file, data, file_siz= e, mem_size, addr, as); } else { - address_space_write(as ? as : &address_space_memory, - addr, MEMTXATTRS_UNSPECIFIED, - data, file_size); + MemTxResult res; + + res =3D address_space_write(as ? as : &address_space_m= emory, + addr, MEMTXATTRS_UNSPECIFIED, + data, file_size); + if (res !=3D MEMTX_OK) { + goto fail; + } } } =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906904; cv=none; d=zohomail.com; s=zohoarc; b=YxDVaVTKu0FlgRAh2cY4xyKf3WmeVJipyze64AfmN4AfABl/UsZctOs355Y5R6AngtN7lZxAocSxO3tkygK0jW0bhT4hTVcxB8VcXIrBGd7y4+WKbxpbJlneU1X4u6/SeP3ij8fk9PmBASlGiiwqGFRYYAyC+94GMp6rXHq8Gos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906904; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jelj5re9VDPgLlS1Rkx1bkVLzds8Xhf8jBxfFi0V9HY=; b=XWGY9iQMPX2HtpmsdCD+/LCzO5GvDR5fprrtnIANbGXLtifsYnkosK7LhzBTXj28/8vTx1rqIvo8C35cddCs+yXimCPTXImayFJe8QsFJrcGpCE80a979gdVY8AmfkkpR/MuuyKwBZvRJt9mQ0SHvdkarGDIm46uRtWvtTf7vKQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906904085369.45895236839056; Thu, 11 Jun 2020 13:21:44 -0700 (PDT) Received: from localhost ([::1]:55476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjThm-0007vq-GJ for importer@patchew.org; Thu, 11 Jun 2020 16:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9h-0000U2-Ak for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49975 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9e-0001IR-N0 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-O59X1wfHNlubvYXM2Qxx1Q-1; Thu, 11 Jun 2020 15:45:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 353FA461; Thu, 11 Jun 2020 19:45:39 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1F3E619C8; Thu, 11 Jun 2020 19:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904785; 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=jelj5re9VDPgLlS1Rkx1bkVLzds8Xhf8jBxfFi0V9HY=; b=iP4rEnfcuKLYqh+2smYJ26Fw5+rfw3OQM6UKc9uNO2x+yCCO+JGoFlkie0ysSn1K/X6eu6 9ODG150odS4PnFINKSop9Ug3dN7arncpd0JbC0O1fY2zYNXFIsx8mRKFlBncVgTIw0CDSL v2uLJsIMhUkdMQEh7e+MQHELfnCr6TY= X-MC-Unique: O59X1wfHNlubvYXM2Qxx1Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 060/115] target/i386: fix floating-point load-constant rounding Date: Thu, 11 Jun 2020 15:43:54 -0400 Message-Id: <20200611194449.31468-61-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The implementations of the fldl2t, fldl2e, fldpi, fldlg2 and fldln2 instructions load fixed constants independent of the rounding mode. Fix them to load a value correctly rounded for the current rounding mode (but always rounded to 64-bit precision independent of the precision control, and without setting "inexact") as specified. Signed-off-by: Joseph Myers Reviewed-by: Richard Henderson Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 54 +++++++- tests/tcg/i386/test-i386-fldcst.c | 199 ++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fldcst.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 4d14c1ca24..f0b9cb5de8 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -59,8 +59,13 @@ #define FPUC_EM 0x3f =20 #define floatx80_lg2 make_floatx80(0x3ffd, 0x9a209a84fbcff799LL) +#define floatx80_lg2_d make_floatx80(0x3ffd, 0x9a209a84fbcff798LL) #define floatx80_l2e make_floatx80(0x3fff, 0xb8aa3b295c17f0bcLL) +#define floatx80_l2e_d make_floatx80(0x3fff, 0xb8aa3b295c17f0bbLL) #define floatx80_l2t make_floatx80(0x4000, 0xd49a784bcd1b8afeLL) +#define floatx80_l2t_u make_floatx80(0x4000, 0xd49a784bcd1b8affLL) +#define floatx80_ln2_d make_floatx80(0x3ffe, 0xb17217f7d1cf79abLL) +#define floatx80_pi_d make_floatx80(0x4000, 0xc90fdaa22168c234LL) =20 #if !defined(CONFIG_USER_ONLY) static qemu_irq ferr_irq; @@ -544,27 +549,66 @@ void helper_fld1_ST0(CPUX86State *env) =20 void helper_fldl2t_ST0(CPUX86State *env) { - ST0 =3D floatx80_l2t; + switch (env->fpuc & FPU_RC_MASK) { + case FPU_RC_UP: + ST0 =3D floatx80_l2t_u; + break; + default: + ST0 =3D floatx80_l2t; + break; + } } =20 void helper_fldl2e_ST0(CPUX86State *env) { - ST0 =3D floatx80_l2e; + switch (env->fpuc & FPU_RC_MASK) { + case FPU_RC_DOWN: + case FPU_RC_CHOP: + ST0 =3D floatx80_l2e_d; + break; + default: + ST0 =3D floatx80_l2e; + break; + } } =20 void helper_fldpi_ST0(CPUX86State *env) { - ST0 =3D floatx80_pi; + switch (env->fpuc & FPU_RC_MASK) { + case FPU_RC_DOWN: + case FPU_RC_CHOP: + ST0 =3D floatx80_pi_d; + break; + default: + ST0 =3D floatx80_pi; + break; + } } =20 void helper_fldlg2_ST0(CPUX86State *env) { - ST0 =3D floatx80_lg2; + switch (env->fpuc & FPU_RC_MASK) { + case FPU_RC_DOWN: + case FPU_RC_CHOP: + ST0 =3D floatx80_lg2_d; + break; + default: + ST0 =3D floatx80_lg2; + break; + } } =20 void helper_fldln2_ST0(CPUX86State *env) { - ST0 =3D floatx80_ln2; + switch (env->fpuc & FPU_RC_MASK) { + case FPU_RC_DOWN: + case FPU_RC_CHOP: + ST0 =3D floatx80_ln2_d; + break; + default: + ST0 =3D floatx80_ln2; + break; + } } =20 void helper_fldz_ST0(CPUX86State *env) diff --git a/tests/tcg/i386/test-i386-fldcst.c b/tests/tcg/i386/test-i386-f= ldcst.c new file mode 100644 index 0000000000..e635432ccf --- /dev/null +++ b/tests/tcg/i386/test-i386-fldcst.c @@ -0,0 +1,199 @@ +/* Test instructions loading floating-point constants. */ + +#include +#include + +volatile long double ld_res; + +int main(void) +{ + short cw; + int ret =3D 0; + + /* Round to nearest. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x000; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2t" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.5269e12f346e2bf8p+0L) { + printf("FAIL: fldl2t N\n"); + ret =3D 1; + } + /* Round downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2t" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.5269e12f346e2bf8p+0L) { + printf("FAIL: fldl2t D\n"); + ret =3D 1; + } + /* Round toward zero. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0xc00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2t" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.5269e12f346e2bf8p+0L) { + printf("FAIL: fldl2t Z\n"); + ret =3D 1; + } + /* Round upward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x800; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2t" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.5269e12f346e2bfcp+0L) { + printf("FAIL: fldl2t U\n"); + ret =3D 1; + } + + /* Round to nearest. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x000; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2e" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x1.71547652b82fe178p+0L) { + printf("FAIL: fldl2e N\n"); + ret =3D 1; + } + /* Round downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2e" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x1.71547652b82fe176p+0L) { + printf("FAIL: fldl2e D\n"); + ret =3D 1; + } + /* Round toward zero. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0xc00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2e" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x1.71547652b82fe176p+0L) { + printf("FAIL: fldl2e Z\n"); + ret =3D 1; + } + /* Round upward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x800; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldl2e" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x1.71547652b82fe178p+0L) { + printf("FAIL: fldl2e U\n"); + ret =3D 1; + } + + /* Round to nearest. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x000; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldpi" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.243f6a8885a308d4p+0L) { + printf("FAIL: fldpi N\n"); + ret =3D 1; + } + /* Round downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldpi" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.243f6a8885a308dp+0L) { + printf("FAIL: fldpi D\n"); + ret =3D 1; + } + /* Round toward zero. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0xc00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldpi" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.243f6a8885a308dp+0L) { + printf("FAIL: fldpi Z\n"); + ret =3D 1; + } + /* Round upward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x800; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldpi" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x3.243f6a8885a308d4p+0L) { + printf("FAIL: fldpi U\n"); + ret =3D 1; + } + + /* Round to nearest. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x000; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldlg2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x4.d104d427de7fbcc8p-4L) { + printf("FAIL: fldlg2 N\n"); + ret =3D 1; + } + /* Round downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldlg2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x4.d104d427de7fbccp-4L) { + printf("FAIL: fldlg2 D\n"); + ret =3D 1; + } + /* Round toward zero. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0xc00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldlg2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x4.d104d427de7fbccp-4L) { + printf("FAIL: fldlg2 Z\n"); + ret =3D 1; + } + /* Round upward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x800; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldlg2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0x4.d104d427de7fbcc8p-4L) { + printf("FAIL: fldlg2 U\n"); + ret =3D 1; + } + + /* Round to nearest. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x000; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldln2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0xb.17217f7d1cf79acp-4L) { + printf("FAIL: fldln2 N\n"); + ret =3D 1; + } + /* Round downward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x400; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldln2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0xb.17217f7d1cf79abp-4L) { + printf("FAIL: fldln2 D\n"); + ret =3D 1; + } + /* Round toward zero. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0xc00; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldln2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0xb.17217f7d1cf79abp-4L) { + printf("FAIL: fldln2 Z\n"); + ret =3D 1; + } + /* Round upward. */ + __asm__ volatile ("fnstcw %0" : "=3Dm" (cw)); + cw =3D (cw & ~0xc00) | 0x800; + __asm__ volatile ("fldcw %0" : : "m" (cw)); + __asm__ volatile ("fldln2" : "=3Dt" (ld_res)); + if (ld_res !=3D 0xb.17217f7d1cf79acp-4L) { + printf("FAIL: fldln2 U\n"); + ret =3D 1; + } + + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906925; cv=none; d=zohomail.com; s=zohoarc; b=K+Y2VS3ZibuxtLZV9GtG3zv7duFaCG8XP1yGf+MuZ7cJxEbMt7o0Wv9fw5qZOsi0Rt7io1uXPrABFYwVqdfBwvqzTiA2nqsiAPTk7hG7tXw0OWLY8rZ1Pg0fFM4e+PMazAZhSUODTC3bJopZHg/RCO5Sk0YiKa2M9l65Fi0C8Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906925; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m1RleRQIoquv/E3/k8PdDFQo2pginmbhyLe5m5S/H8I=; b=IPQun3MlpwbHBieM+3I/TcmRbdvAZjlTtt/lCMISDBH4wZz0TVk4V49r90fOt+I/ffA8M3k2gt0w3VE+LUm5Kidl//b5vejLgic+aAU+Hfx8ymNqVvGkZuK+b3DVQozUcCoTVl7N5jE44mRFWneFkCG5C8vtk/zwYYnW/Qghsro= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906925108285.3500224742969; Thu, 11 Jun 2020 13:22:05 -0700 (PDT) Received: from localhost ([::1]:56638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTi7-0008OF-RM for importer@patchew.org; Thu, 11 Jun 2020 16:22:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT91-00083C-28 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:47 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59228 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8x-000174-MJ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-FdaCB6zNO1iajbf3xzfpPQ-1; Thu, 11 Jun 2020 15:45:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D326F80B71E; Thu, 11 Jun 2020 19:45:39 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 664132AF4D; Thu, 11 Jun 2020 19:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904742; 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=m1RleRQIoquv/E3/k8PdDFQo2pginmbhyLe5m5S/H8I=; b=H1TtIVR+EmG2HVLYOBC6isVE2mPUCI0dF4k2e10xxSvJtXMnVeHPKYTxr8BH+XjiKX/Azz mcEaGKedt/9f4S759RFJQEFzXypAb5onLOicP4tpxcz5ItPl2V9/wObeO7vDYU1vvrYBx2 vTg0898X077NR83XDo88KbhUvbXzRtQ= X-MC-Unique: FdaCB6zNO1iajbf3xzfpPQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 061/115] target/i386: fix fxam handling of invalid encodings Date: Thu, 11 Jun 2020 15:43:55 -0400 Message-Id: <20200611194449.31468-62-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fxam implementation does not check for invalid encodings, instead treating them like NaN or normal numbers depending on the exponent. Fix it to check that the high bit of the significand is set before treating an encoding as NaN or normal, thus resulting in correct handling (all of C0, C2 and C3 cleared) for invalid encodings. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 4 +- tests/tcg/i386/test-i386-fxam.c | 143 ++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fxam.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index f0b9cb5de8..185493db8e 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -1099,7 +1099,7 @@ void helper_fxam_ST0(CPUX86State *env) if (expdif =3D=3D MAXEXPD) { if (MANTD(temp) =3D=3D 0x8000000000000000ULL) { env->fpus |=3D 0x500; /* Infinity */ - } else { + } else if (MANTD(temp) & 0x8000000000000000ULL) { env->fpus |=3D 0x100; /* NaN */ } } else if (expdif =3D=3D 0) { @@ -1108,7 +1108,7 @@ void helper_fxam_ST0(CPUX86State *env) } else { env->fpus |=3D 0x4400; /* Denormal */ } - } else { + } else if (MANTD(temp) & 0x8000000000000000ULL) { env->fpus |=3D 0x400; } } diff --git a/tests/tcg/i386/test-i386-fxam.c b/tests/tcg/i386/test-i386-fxa= m.c new file mode 100644 index 0000000000..ddd76ca42d --- /dev/null +++ b/tests/tcg/i386/test-i386-fxam.c @@ -0,0 +1,143 @@ +/* Test fxam instruction. */ + +#include +#include + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile union u ld_pseudo_m16382 =3D { .s =3D { UINT64_C(1) << 63, 0 } }; +volatile union u ld_pseudo_nm16382 =3D { .s =3D { UINT64_C(1) << 63, 0x800= 0 } }; +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; +volatile union u ld_invalid_2 =3D { .s =3D { 0, 1234 } }; +volatile union u ld_invalid_3 =3D { .s =3D { 0, 0x7fff } }; +volatile union u ld_invalid_4 =3D { .s =3D { (UINT64_C(1) << 63) - 1, 0x7f= ff } }; +volatile union u ld_invalid_n1 =3D { .s =3D { 1, 0x8123 } }; +volatile union u ld_invalid_n2 =3D { .s =3D { 0, 0x8123 } }; +volatile union u ld_invalid_n3 =3D { .s =3D { 0, 0xffff } }; +volatile union u ld_invalid_n4 =3D { .s =3D { (UINT64_C(1) << 63) - 1, 0xf= fff } }; + +#define C0 (1 << 8) +#define C1 (1 << 9) +#define C2 (1 << 10) +#define C3 (1 << 14) +#define FLAGS (C0 | C1 | C2 | C3) + +int main(void) +{ + short sw; + int ret =3D 0; + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (0.0L)); + if ((sw & FLAGS) !=3D C3) { + printf("FAIL: +0\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-0.0L)); + if ((sw & FLAGS) !=3D (C3 | C1)) { + printf("FAIL: -0\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (1.0L)); + if ((sw & FLAGS) !=3D C2) { + printf("FAIL: +normal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-1.0L)); + if ((sw & FLAGS) !=3D (C2 | C1)) { + printf("FAIL: -normal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (__builtin_infl()= )); + if ((sw & FLAGS) !=3D (C2 | C0)) { + printf("FAIL: +inf\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-__builtin_infl(= ))); + if ((sw & FLAGS) !=3D (C2 | C1 | C0)) { + printf("FAIL: -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (__builtin_nanl("= "))); + if ((sw & FLAGS) !=3D C0) { + printf("FAIL: +nan\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-__builtin_nanl(= ""))); + if ((sw & FLAGS) !=3D (C1 | C0)) { + printf("FAIL: -nan\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (__builtin_nansl(= ""))); + if ((sw & FLAGS) !=3D C0) { + printf("FAIL: +snan\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-__builtin_nansl= (""))); + if ((sw & FLAGS) !=3D (C1 | C0)) { + printf("FAIL: -snan\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (0x1p-16445L)); + if ((sw & FLAGS) !=3D (C3 | C2)) { + printf("FAIL: +denormal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (-0x1p-16445L)); + if ((sw & FLAGS) !=3D (C3 | C2 | C1)) { + printf("FAIL: -denormal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_pseudo_m16382= .ld)); + if ((sw & FLAGS) !=3D (C3 | C2)) { + printf("FAIL: +pseudo-denormal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_pseudo_nm1638= 2.ld)); + if ((sw & FLAGS) !=3D (C3 | C2 | C1)) { + printf("FAIL: -pseudo-denormal\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_1.ld)= ); + if ((sw & FLAGS) !=3D 0) { + printf("FAIL: +invalid 1\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_n1.ld= )); + if ((sw & FLAGS) !=3D C1) { + printf("FAIL: -invalid 1\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_2.ld)= ); + if ((sw & FLAGS) !=3D 0) { + printf("FAIL: +invalid 2\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_n2.ld= )); + if ((sw & FLAGS) !=3D C1) { + printf("FAIL: -invalid 2\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_3.ld)= ); + if ((sw & FLAGS) !=3D 0) { + printf("FAIL: +invalid 3\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_n3.ld= )); + if ((sw & FLAGS) !=3D C1) { + printf("FAIL: -invalid 3\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_4.ld)= ); + if ((sw & FLAGS) !=3D 0) { + printf("FAIL: +invalid 4\n"); + ret =3D 1; + } + __asm__ volatile ("fxam\nfnstsw" : "=3Da" (sw) : "t" (ld_invalid_n4.ld= )); + if ((sw & FLAGS) !=3D C1) { + printf("FAIL: -invalid 4\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907217; cv=none; d=zohomail.com; s=zohoarc; b=X7yt9kK4p0IaKO6YivmpdZT2vXc0XX6pgBgU2cb7ltriojGg6k3y3GpGVGBg/JYFtUsFfJMunHHPz0KFcQXBu2BaEW/Cn5FIXaLMKp0KJZKmjFUBcBrFGDhD6mnUGaORIiaayXsS1DZmsbqWzKl4sb3lPPAsGjuM/zNL6Fxt8r4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PixQXutwcGEY5jlx8dUr7LAWNxKmNvIVWkqYGwJzOgI=; b=BP5/ifcyz0zwkskQvUqZ11hMrwY6SjCnCrdmnj2UaLhxmX5oQhAY2HZ1By6UiTRVXiHGldKJvVQSe8SbZ4Ln0OfJV3OQizZego0yapHSQuL2YEpe9gSDYAugaRTsFX+BJLtWg76VYWo8et0ISm7bt2E8QVJvgcThIFVAXj+SDsc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907217421679.4794796742378; Thu, 11 Jun 2020 13:26:57 -0700 (PDT) Received: from localhost ([::1]:45248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTmo-0007xS-3i for importer@patchew.org; Thu, 11 Jun 2020 16:26:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT92-000860-64 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44893 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8y-00017q-Hk for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-AUEd9WlAOrWLVLnWeRo31Q-1; Thu, 11 Jun 2020 15:45:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CB191800D41; Thu, 11 Jun 2020 19:45:40 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FCDB61169; Thu, 11 Jun 2020 19:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904743; 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=PixQXutwcGEY5jlx8dUr7LAWNxKmNvIVWkqYGwJzOgI=; b=KW3y33LL9Yodz1KZb/Ks+Cjwft9TZ95PWZmoWDHUL8EPK3n3KoSSVDzLqoj8naT8lCHWSN pNT47L1M3crl/bKnbseOYTX9XbX7mkAPJY4xTkjD0mwD4i0x4Szn7C4Q4aPjS+wgfoF5Gr T2RNoKopQxtZ27PuQJbMz3hqFaS7imU= X-MC-Unique: AUEd9WlAOrWLVLnWeRo31Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 062/115] target/i386: fix fbstp handling of negative zero Date: Thu, 11 Jun 2020 15:43:56 -0400 Message-Id: <20200611194449.31468-63-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fbstp implementation stores +0 when the rounded result should be -0 because it compares an integer value with 0 to determine the sign. Fix this by checking the sign bit of the operand instead. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 5 ++++- tests/tcg/i386/test-i386-fbstp.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/i386/test-i386-fbstp.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 185493db8e..f0a57099ca 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -726,11 +726,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong p= tr) int v; target_ulong mem_ref, mem_end; int64_t val; + CPU_LDoubleU temp; + + temp.d =3D ST0; =20 val =3D floatx80_to_int64(ST0, &env->fp_status); mem_ref =3D ptr; mem_end =3D mem_ref + 9; - if (val < 0) { + if (SIGND(temp)) { cpu_stb_data_ra(env, mem_end, 0x80, GETPC()); val =3D -val; } else { diff --git a/tests/tcg/i386/test-i386-fbstp.c b/tests/tcg/i386/test-i386-fb= stp.c new file mode 100644 index 0000000000..d368949188 --- /dev/null +++ b/tests/tcg/i386/test-i386-fbstp.c @@ -0,0 +1,25 @@ +/* Test fbstp instruction. */ + +#include +#include + +int main(void) +{ + int ret =3D 0; + unsigned char out[10]; + memset(out, 0xfe, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-0.0L) : "st"); + out[9] &=3D 0x80; + if (memcmp(out, "\0\0\0\0\0\0\0\0\0\x80", sizeof out) !=3D 0) { + printf("FAIL: fbstp -0\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-0.1L) : "st"); + out[9] &=3D 0x80; + if (memcmp(out, "\0\0\0\0\0\0\0\0\0\x80", sizeof out) !=3D 0) { + printf("FAIL: fbstp -0.1\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907341; cv=none; d=zohomail.com; s=zohoarc; b=jvTo6535A2zCs2+HYFKnDGO6sU6qRZnHPPcm63Ul/e+qz/JtoJKFbtLpezk0syQD/usXccISPZudyBK7Ih6g6fgDEell0lyGI5u0NBJYXGnmd156K8gxEFlq9U0WPq5Y8jGPVs6iTCorYVnIxmbJ2m5d2ELuUeyZI/ApUFx3jq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fc5C2D8Qy2Ifc39GMfOK5qBTqHLI5bHmpAMB0Ujy/Lk=; b=LTO5Vk3UFG+kY494vLSmnjGOyxo932AXVVAW00WrYXB56Tax7jVEnTwc0Q4iT3Qf6D/LnCNRsL9/c+wP+c/vOCqsa8yJwzSnLcHiZb4i1S88GB54bmTr0DbnxrZ6x106Cn6hmYTas5MV7+k2dJ8+iY0hzqCTFIirPltQdYuNYTQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190734181483.71900509140869; Thu, 11 Jun 2020 13:29:01 -0700 (PDT) Received: from localhost ([::1]:53830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjToq-0003MB-Ik for importer@patchew.org; Thu, 11 Jun 2020 16:29:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT92-00086h-UR for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49227 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8z-00018D-7i for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-nI6nhJbQOjut-Qr7L6Todg-1; Thu, 11 Jun 2020 15:45:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2744819067F2; Thu, 11 Jun 2020 19:45:41 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD8C662502; Thu, 11 Jun 2020 19:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904744; 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=fc5C2D8Qy2Ifc39GMfOK5qBTqHLI5bHmpAMB0Ujy/Lk=; b=B/kNrv1qN3Mh2rltT1RqWBhWl0vIFTRjjI151bqZuGUBFBSbT5tCUJh2yB4r91ZdhK056f myVna3pnUiXUtorH8j5pD1RReI6Ud4UuKiYNduv9ZavhEEqI8BQUbhTVOAN/Vl9AWFxVuA tbS/2PLfnCIGcu6cv+T1TMdjZ/amgZ4= X-MC-Unique: nI6nhJbQOjut-Qr7L6Todg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 063/115] target/i386: fix fbstp handling of out-of-range values Date: Thu, 11 Jun 2020 15:43:57 -0400 Message-Id: <20200611194449.31468-64-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fbstp implementation fails to check for out-of-range and invalid values, instead just taking the result of conversion to int64_t and storing its sign and low 18 decimal digits. Fix this by checking for an out-of-range result (invalid conversions always result in INT64_MAX or INT64_MIN from the softfloat code, which are large enough to be considered as out-of-range by this code) and storing the packed BCD indefinite encoding in that case. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 10 +++ tests/tcg/i386/test-i386-fbstp.c | 115 +++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index f0a57099ca..41f6f391ca 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -732,6 +732,16 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong pt= r) =20 val =3D floatx80_to_int64(ST0, &env->fp_status); mem_ref =3D ptr; + if (val >=3D 1000000000000000000LL || val <=3D -1000000000000000000LL)= { + float_raise(float_flag_invalid, &env->fp_status); + while (mem_ref < ptr + 7) { + cpu_stb_data_ra(env, mem_ref++, 0, GETPC()); + } + cpu_stb_data_ra(env, mem_ref++, 0xc0, GETPC()); + cpu_stb_data_ra(env, mem_ref++, 0xff, GETPC()); + cpu_stb_data_ra(env, mem_ref++, 0xff, GETPC()); + return; + } mem_end =3D mem_ref + 9; if (SIGND(temp)) { cpu_stb_data_ra(env, mem_end, 0x80, GETPC()); diff --git a/tests/tcg/i386/test-i386-fbstp.c b/tests/tcg/i386/test-i386-fb= stp.c index d368949188..73bf56b9dc 100644 --- a/tests/tcg/i386/test-i386-fbstp.c +++ b/tests/tcg/i386/test-i386-fbstp.c @@ -1,8 +1,19 @@ /* Test fbstp instruction. */ =20 +#include #include #include =20 +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; +volatile union u ld_invalid_2 =3D { .s =3D { 0, 1234 } }; +volatile union u ld_invalid_3 =3D { .s =3D { 0, 0x7fff } }; +volatile union u ld_invalid_4 =3D { .s =3D { (UINT64_C(1) << 63) - 1, 0x7f= ff } }; + int main(void) { int ret =3D 0; @@ -21,5 +32,109 @@ int main(void) printf("FAIL: fbstp -0.1\n"); ret =3D 1; } + memset(out, 0x1f, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-987654321987654321= .0L) : + "st"); + out[9] &=3D 0x80; + if (memcmp(out, "\x21\x43\x65\x87\x19\x32\x54\x76\x98\x80", + sizeof out) !=3D 0) { + printf("FAIL: fbstp -987654321987654321\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (999999999999999999.= 5L) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp 999999999999999999.5\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (1000000000000000000= .0L) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp 1000000000000000000\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (1e30L) : "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp 1e30\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-999999999999999999= .5L) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp -999999999999999999.5\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-100000000000000000= 0.0L) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp -1000000000000000000\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-1e30L) : "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp -1e30\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (__builtin_infl()) := "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp inf\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-__builtin_infl()) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp -inf\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (__builtin_nanl(""))= : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp nan\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-__builtin_nanl("")= ) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp -nan\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_invalid_1.ld) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp invalid 1\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_invalid_2.ld) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp invalid 2\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_invalid_3.ld) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp invalid 3\n"); + ret =3D 1; + } + memset(out, 0x12, sizeof out); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_invalid_4.ld) : + "st"); + if (memcmp(out, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out) !=3D 0) { + printf("FAIL: fbstp invalid 4\n"); + ret =3D 1; + } return ret; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906511; cv=none; d=zohomail.com; s=zohoarc; b=ndP9fP0ylX5s+q7d/14k4QKNDr1LU+Ot0hUvFVc8vdT2YLczdi+BCPrvwCzyfoSW/MtBZCHDWDn8s37xsH4Ghb7wkuyJWarYkje6hlhU1A0tGhkuFVxmYM0+A0vFbfGmk5+mkpRX5nVFpDv1cY6lj397WWn6EI3GNEp0CZ2gs3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906511; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R33mP9vMfsFFS6scj4tu07aOYyJWL6/9GYRUw28mqtE=; b=Mu+iJBUnIyC+erXemNL1+DG0x6Ez2HSiaYdTA/M4CoZNKhSt2UDZlMq+1j1hZMvEUQreRwgGL4zZe1raXeP9JM/cGU66iPVqu6TpIkIBW5aUIdDLZguOAVKU2HYVsoERIJAdNYObQNKQIyXQdZF7ULFIeVATMXFYhnsNYvI+UkY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906511256783.897954811067; Thu, 11 Jun 2020 13:15:11 -0700 (PDT) Received: from localhost ([::1]:57982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTbR-0003s3-V0 for importer@patchew.org; Thu, 11 Jun 2020 16:15:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT98-00086r-7B for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:55 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:53081 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT8z-00018M-Ec for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-qoMAg_mFOWO0sd4z8b9jgw-1; Thu, 11 Jun 2020 15:45:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4F0B846363; Thu, 11 Jun 2020 19:45:41 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5802F500D3; Thu, 11 Jun 2020 19:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904744; 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=R33mP9vMfsFFS6scj4tu07aOYyJWL6/9GYRUw28mqtE=; b=BLBAGrptxMFJP24Hp4JZWoKIIqedRl2/qnzy/fIOqUgNLoZu7gApl0gHXTHvGygUaDCWGL WzB2pqk6wjc0ts2Bp0U5+6Ihn6lsSReZl47f0NT0f4XDBSQgzdV2zGh38dyAFlzxkilkIY paf8ovnpWxKENSya2XU1qpr4GLXRnAQ= X-MC-Unique: qoMAg_mFOWO0sd4z8b9jgw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 064/115] target/i386: fix fisttpl, fisttpll handling of out-of-range values Date: Thu, 11 Jun 2020 15:43:58 -0400 Message-Id: <20200611194449.31468-65-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers The fist / fistt family of instructions should all store the most negative integer in the destination format when the rounded / truncated integer result is out of range or the input is an invalid encoding, infinity or NaN. The fisttpl and fisttpll implementations (32-bit and 64-bit results, truncate towards zero) failed to do this, producing the most positive integer in some cases instead. Fix this by copying the code used to handle this issue for fistpl and fistpll, adjusted to use the _round_to_zero functions for the actual conversion (but without any other changes to that code). Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 28 ++++++++- tests/tcg/i386/test-i386-fisttp.c | 100 ++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fisttp.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 41f6f391ca..9c93f385b1 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -338,12 +338,36 @@ int32_t helper_fistt_ST0(CPUX86State *env) =20 int32_t helper_fisttl_ST0(CPUX86State *env) { - return floatx80_to_int32_round_to_zero(ST0, &env->fp_status); + int32_t val; + signed char old_exp_flags; + + old_exp_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + + val =3D floatx80_to_int32_round_to_zero(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { + val =3D 0x80000000; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); + return val; } =20 int64_t helper_fisttll_ST0(CPUX86State *env) { - return floatx80_to_int64_round_to_zero(ST0, &env->fp_status); + int64_t val; + signed char old_exp_flags; + + old_exp_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + + val =3D floatx80_to_int64_round_to_zero(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { + val =3D 0x8000000000000000ULL; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); + return val; } =20 void helper_fldt_ST0(CPUX86State *env, target_ulong ptr) diff --git a/tests/tcg/i386/test-i386-fisttp.c b/tests/tcg/i386/test-i386-f= isttp.c new file mode 100644 index 0000000000..16af59a774 --- /dev/null +++ b/tests/tcg/i386/test-i386-fisttp.c @@ -0,0 +1,100 @@ +/* Test fisttpl and fisttpll instructions. */ + +#include +#include +#include + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; + +int main(void) +{ + int ret =3D 0; + int32_t res_32; + int64_t res_64; + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (0x1p100L) : "s= t"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl 0x1p100\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (-0x1p100L) : "= st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl -0x1p100\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (__builtin_infl= ()) : + "st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl inf\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (-__builtin_inf= l()) : + "st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (__builtin_nanl= ("")) : + "st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl nan\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : + "t" (-__builtin_nanl("")) : "st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl -nan\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (ld_invalid_1.l= d) : + "st"); + if (res_32 !=3D INT32_MIN) { + printf("FAIL: fisttpl invalid\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (0x1p100L) : "= st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll 0x1p100\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (-0x1p100L) : = "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll -0x1p100\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (__builtin_inf= l()) : + "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll inf\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (-__builtin_in= fl()) : + "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : + "t" (__builtin_nanl("")) : "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll nan\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : + "t" (-__builtin_nanl("")) : "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll -nan\n"); + ret =3D 1; + } + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (ld_invalid_1.= ld) : + "st"); + if (res_64 !=3D INT64_MIN) { + printf("FAIL: fisttpll invalid\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907139; cv=none; d=zohomail.com; s=zohoarc; b=jmJ5a5Rz9YAYvt1KP+5kkK+IK5o3elsutyKDIXKnJI7WfK9x/4V/VlM/AZaN1TFWV82sDF6SGOrBbLvLSMTBD31JIDe7mRXzO5tAKzCPbD6LaJnQ8I4/kPyw5EksqQh6fK7YEFXpdRRxODZwTKjKYntPOQEeglOttAZ/A/WbA50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907139; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xsno5tlvM6Jk1Psxj6i69cWNRmy6+Mz9lMv8WAnRyrc=; b=Ya5denVM3hYpSJ+kJ5U+514szb/sRrjqIITsPNTdvjad5cP4qx1Ygu/QEoWWbc8064freui8OK3DWzTK4LyFuxhLQSbMxkF/TilJcFAqycWM7/U/+8uB0RaIeksxW5Jp/aMKM07cOnyrRR5IY/acBFaQL/1qSzzezV4uPeSijjU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907139918368.06129401793055; Thu, 11 Jun 2020 13:25:39 -0700 (PDT) Received: from localhost ([::1]:39946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTla-0005gm-FU for importer@patchew.org; Thu, 11 Jun 2020 16:25:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT98-00086t-9B for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27187 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT90-00018y-Cf for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:45:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-uav9ZJblO_681N0rq2gBvA-1; Thu, 11 Jun 2020 15:45:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 703768015CE; Thu, 11 Jun 2020 19:45:42 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02ED562509; Thu, 11 Jun 2020 19:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904745; 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=xsno5tlvM6Jk1Psxj6i69cWNRmy6+Mz9lMv8WAnRyrc=; b=YHppnoVaNuMD51WyKZ+hwnAQSvKXBbXDYLAcWFVVQlk/hqA6P0SZNaQScB/ugafX01MyDT LLHM1NBl/0BgvZs9U47ngwdPVTLZSGdVlh5FfP3DR0eDA1D+568RyasLvNWsLpzUReJyTT k2Psetwv1qHZfjHPXHztK+Q1hbdIhNU= X-MC-Unique: uav9ZJblO_681N0rq2gBvA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 065/115] hw/i386/vmport: Allow QTest use without crashing Date: Thu, 11 Jun 2020 15:43:59 -0400 Message-Id: <20200611194449.31468-66-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Trying libFuzzer on the vmport device, we get: AddressSanitizer:DEADLYSIGNAL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D29476=3D=3DERROR: AddressSanitizer: SEGV on unknown address 0x00000= 0008840 (pc 0x56448bec4d79 bp 0x7ffeec9741b0 sp 0x7ffeec9740e0 T0) =3D=3D29476=3D=3DThe signal is caused by a READ memory access. #0 0x56448bec4d78 in vmport_ioport_read (qemu-fuzz-i386+0x1260d78) #1 0x56448bb5f175 in memory_region_read_accessor (qemu-fuzz-i386+0xefb1= 75) #2 0x56448bb30c13 in access_with_adjusted_size (qemu-fuzz-i386+0xeccc13) #3 0x56448bb2ea27 in memory_region_dispatch_read1 (qemu-fuzz-i386+0xeca= a27) #4 0x56448bb2e443 in memory_region_dispatch_read (qemu-fuzz-i386+0xeca4= 43) #5 0x56448b961ab1 in flatview_read_continue (qemu-fuzz-i386+0xcfdab1) #6 0x56448b96336d in flatview_read (qemu-fuzz-i386+0xcff36d) #7 0x56448b962ec4 in address_space_read_full (qemu-fuzz-i386+0xcfeec4) This is easily reproducible using: $ echo inb 0x5658 | qemu-system-i386 -M isapc,accel=3Dqtest -qtest stdio [I 1589796572.009763] OPENED [R +0.008069] inb 0x5658 Segmentation fault (core dumped) $ coredumpctl gdb -q Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00005605b54d0f21 in vmport_ioport_read (opaque=3D0x5605b7531ce0, ad= dr=3D0, size=3D4) at hw/i386/vmport.c:77 77 eax =3D env->regs[R_EAX]; (gdb) p cpu $1 =3D (X86CPU *) 0x0 (gdb) bt #0 0x00005605b54d0f21 in vmport_ioport_read (opaque=3D0x5605b7531ce0, ad= dr=3D0, size=3D4) at hw/i386/vmport.c:77 #1 0x00005605b53db114 in memory_region_read_accessor (mr=3D0x5605b7531d8= 0, addr=3D0, value=3D0x7ffc9d261a30, size=3D4, shift=3D0, mask=3D4294967295= , attrs=3D...) at memory.c:434 #2 0x00005605b53db5d4 in access_with_adjusted_size (addr=3D0, value=3D0x= 7ffc9d261a30, size=3D1, access_size_min=3D4, access_size_max=3D4, access_fn= =3D 0x5605b53db0d2 , mr=3D0x5605b7531d80, at= trs=3D...) at memory.c:544 #3 0x00005605b53de156 in memory_region_dispatch_read1 (mr=3D0x5605b7531d= 80, addr=3D0, pval=3D0x7ffc9d261a30, size=3D1, attrs=3D...) at memory.c:1396 #4 0x00005605b53de228 in memory_region_dispatch_read (mr=3D0x5605b7531d8= 0, addr=3D0, pval=3D0x7ffc9d261a30, op=3DMO_8, attrs=3D...) at memory.c:1424 #5 0x00005605b537c80a in flatview_read_continue (fv=3D0x5605b7650290, ad= dr=3D22104, attrs=3D..., ptr=3D0x7ffc9d261b4b, len=3D1, addr1=3D0, l=3D1, m= r=3D0x5605b7531d80) at exec.c:3200 #6 0x00005605b537c95d in flatview_read (fv=3D0x5605b7650290, addr=3D2210= 4, attrs=3D..., buf=3D0x7ffc9d261b4b, len=3D1) at exec.c:3239 #7 0x00005605b537c9e6 in address_space_read_full (as=3D0x5605b5f74ac0 , addr=3D22104, attrs=3D..., buf=3D0x7ffc9d261b4b, len=3D1)= at exec.c:3252 #8 0x00005605b53d5a5d in address_space_read (len=3D1, buf=3D0x7ffc9d261b= 4b, attrs=3D..., addr=3D22104, as=3D0x5605b5f74ac0 ) at i= nclude/exec/memory.h:2401 #9 0x00005605b53d5a5d in cpu_inb (addr=3D22104) at ioport.c:88 X86CPU is NULL because QTest accelerator does not use CPU. Fix by returning default values when QTest accelerator is used. Reported-by: Clang AddressSanitizer Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- hw/i386/vmport.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 79ef25d223..89bda9108e 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -34,6 +34,7 @@ #include "hw/qdev-properties.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" +#include "sysemu/qtest.h" #include "qemu/log.h" #include "cpu.h" #include "trace.h" @@ -94,10 +95,14 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, VMPortState *s =3D opaque; CPUState *cs =3D current_cpu; X86CPU *cpu =3D X86_CPU(cs); - CPUX86State *env =3D &cpu->env; + CPUX86State *env; unsigned char command; uint32_t eax; =20 + if (qtest_enabled()) { + return -1; + } + env =3D &cpu->env; cpu_synchronize_state(cs); =20 eax =3D env->regs[R_EAX]; @@ -142,6 +147,9 @@ static void vmport_ioport_write(void *opaque, hwaddr ad= dr, { X86CPU *cpu =3D X86_CPU(current_cpu); =20 + if (qtest_enabled()) { + return; + } cpu->env.regs[R_EAX] =3D vmport_ioport_read(opaque, addr, 4); } =20 @@ -149,6 +157,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, ui= nt32_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); =20 + if (qtest_enabled()) { + return -1; + } cpu->env.regs[R_EBX] =3D VMPORT_MAGIC; if (port_state->compat_flags & VMPORT_COMPAT_REPORT_VMX_TYPE) { cpu->env.regs[R_ECX] =3D port_state->vmware_vmx_type; @@ -172,6 +183,9 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint3= 2_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); =20 + if (qtest_enabled()) { + return -1; + } cpu->env.regs[R_EBX] =3D 0x1177; return ram_size; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906640; cv=none; d=zohomail.com; s=zohoarc; b=V9xgaygnqF2sctk+tLw8zoobKwrMa7E1YLLnp85LRTj/v8Spuz/5FfxLmpegDU4dHnJhZJ4GsxmkxlR4FIZ7fbsO3Hiy9x5CqHkJjkj60pPXmaXNxqOWR7c3bmtQdP0uAkIuk9b5+ZIhIQK7x8h8bmscX7gDr1VfCk+N/NpUUiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906640; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kMqQRr9k5XeptG6taIpb/rq7dXuSJToL4tMSW7vxJmA=; b=E0unyKD9EIw6IWd2i37U3tt63+1pEiUyu2yM4X87HidzebJAaRdtZNKD9sbq6iLrzm+1Ys2k/llTL1OVcUGNcv27zsSW0sn5xmUQt6R7Xql221gyJjcq+I91YCunnkx+jFaht/ztyHSOVls3wGyvtliue031N20yzGheXqzBjP4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906640432995.7896477687383; Thu, 11 Jun 2020 13:17:20 -0700 (PDT) Received: from localhost ([::1]:38232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTdW-0007rP-Vq for importer@patchew.org; Thu, 11 Jun 2020 16:17:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9F-00088f-Td for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60138 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT95-0001Br-TH for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456--jifSIU1MYePKMd3dnnJ6A-1; Thu, 11 Jun 2020 15:45:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19E62107ACF4; Thu, 11 Jun 2020 19:45:43 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0FF951C50; Thu, 11 Jun 2020 19:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904749; 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=kMqQRr9k5XeptG6taIpb/rq7dXuSJToL4tMSW7vxJmA=; b=QTjdKUzpkcA+BcrfgJYrno7kYwQeS5MN+3PSLnRlyYUrzDE7T8W/NMuiOZQlLSNhChendQ qQ4iOOhlz1SphsO4gSU3UnUIkFtLXXLoMjwoB+DqmBWDWUESgIR/xUrYjPE6nIoiVK8sNL Na12vVU9i5neFJ4+tJdQ+A8KJBzQcOo= X-MC-Unique: -jifSIU1MYePKMd3dnnJ6A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 066/115] x86/cpu: Enable AVX512_VP2INTERSECT cpu feature Date: Thu, 11 Jun 2020 15:44:00 -0400 Message-Id: <20200611194449.31468-67-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cathy Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Cathy Zhang AVX512_VP2INTERSECT compute vector pair intersection to a pair of mask registers, which is introduced with intel Tiger Lake, defining as CPUID.(EAX=3D7,ECX=3D0):EDX[bit 08]. Refer to the following release spec: https://software.intel.com/sites/default/files/managed/c5/15/\ architecture-instruction-set-extensions-programming-reference.pdf Signed-off-by: Cathy Zhang Message-Id: <1586760758-13638-1-git-send-email-cathy.zhang@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5705cda86..e89d9fa894 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -985,7 +985,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS]= =3D { .feat_names =3D { NULL, NULL, "avx512-4vnniw", "avx512-4fmaps", NULL, NULL, NULL, NULL, - NULL, NULL, "md-clear", NULL, + "avx512-vp2intersect", NULL, "md-clear", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* pconfig */, NULL, NULL, NULL, NULL, NULL, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 37572bd437..100476ee89 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -772,6 +772,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) +/* AVX512 Vector Pair Intersection to a Pair of Mask Registers */ +#define CPUID_7_0_EDX_AVX512_VP2INTERSECT (1U << 8) /* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Single Thread Indirect Branch Predictors */ --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907483; cv=none; d=zohomail.com; s=zohoarc; b=QXLh5KNqYK/L35tOZw85RQmd43lSIhx/lFaageNoT8Hur6Y9JUKvQdYVzih3fp0bHf7TCil/vt0C1saUTjzbJ8a6P9YNWPDN3mEnKAsO2lJRu5/lGn5Yw1bcv1MYil29EqbIODFk49GCPYMoLodtYx2xR9JV8GgUjeYiC61eNBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907483; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KGJrn4mBcuuQPbf5h+fVCvjwwd4L5qQyUYwiSYCkEv4=; b=hVoMGxPBQ/AgK+IG6hk7jqFpiwM7OznXjY/XruprFy04+Vf+DUTwr9meLCvVL69W1O1rqJEfvXbbtR8yJZusmTkvIt+JbqFhc72fjtlsE3qRb/uBDPGe0DtJCJwa1vmtWGSIMpUZaVKYIaoVwkyJR1uDYQWj7AoEjd4KhDiRoU0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907483853130.88368959309742; Thu, 11 Jun 2020 13:31:23 -0700 (PDT) Received: from localhost ([::1]:59950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTr8-0005r4-9d for importer@patchew.org; Thu, 11 Jun 2020 16:31:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjT9Q-0008I4-FJ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37355 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjT9N-0001Dr-Qx for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-K9DwVHw_P-WDhLRWDaJKzg-1; Thu, 11 Jun 2020 15:46:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02610107ACCA for ; Thu, 11 Jun 2020 19:46:06 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AC2051C50; Thu, 11 Jun 2020 19:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904768; 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=KGJrn4mBcuuQPbf5h+fVCvjwwd4L5qQyUYwiSYCkEv4=; b=LBPM3JxvkpOACg5/0p3aBpb+McEX0j+U+5EWr64NaFqQVEIt39MNJ1SNqLV8ctU27E5khL xelqXUAjXzYTVOjVq8tfnCmX28YDPlp3e0Y2SL53YKYNM2c7zpnAVoM7LqFh3NDTxAOBzf hkwjpvCkJHFnVeRqiqAU45qY1Xa2p74= X-MC-Unique: K9DwVHw_P-WDhLRWDaJKzg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 067/115] vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds Date: Thu, 11 Jun 2020 15:44:01 -0400 Message-Id: <20200611194449.31468-68-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Auger , Alex Williamson , Cornelia Huck , Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu VFIO is currently the only one left that is not using the generic function (kvm_irqchip_add_irqfd_notifier_gsi()) to register irqfds. Let VFIO use the common framework too. Follow up patches will introduce extra features for kvm irqfd, so that VFIO can easily leverage that after the switch. Reviewed-by: Eric Auger Reviewed-by: Cornelia Huck Reviewed-by: Alex Williamson Acked-by: Alex Williamson Signed-off-by: Peter Xu Message-Id: <20200318145204.74483-3-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/vfio/pci.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 342dd6b912..6838bcc4b3 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -115,11 +115,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) { #ifdef CONFIG_KVM - struct kvm_irqfd irqfd =3D { - .fd =3D event_notifier_get_fd(&vdev->intx.interrupt), - .gsi =3D vdev->intx.route.irq, - .flags =3D KVM_IRQFD_FLAG_RESAMPLE, - }; + int irq_fd =3D event_notifier_get_fd(&vdev->intx.interrupt); Error *err =3D NULL; =20 if (vdev->no_kvm_intx || !kvm_irqfds_enabled() || @@ -129,7 +125,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) } =20 /* Get to a known interrupt state */ - qemu_set_fd_handler(irqfd.fd, NULL, NULL, vdev); + qemu_set_fd_handler(irq_fd, NULL, NULL, vdev); vfio_mask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); @@ -140,17 +136,18 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev,= Error **errp) goto fail; } =20 - /* KVM triggers it, VFIO listens for it */ - irqfd.resamplefd =3D event_notifier_get_fd(&vdev->intx.unmask); - - if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) { + if (kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, + &vdev->intx.interrupt, + &vdev->intx.unmask, + vdev->intx.route.irq)) { error_setg_errno(errp, errno, "failed to setup resample irqfd"); goto fail_irqfd; } =20 if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, VFIO_IRQ_SET_ACTION_UNMASK, - irqfd.resamplefd, &err)) { + event_notifier_get_fd(&vdev->intx.unmask), + &err)) { error_propagate(errp, err); goto fail_vfio; } @@ -165,12 +162,12 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev,= Error **errp) return; =20 fail_vfio: - irqfd.flags =3D KVM_IRQFD_FLAG_DEASSIGN; - kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd); + kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &vdev->intx.interrupt, + vdev->intx.route.irq); fail_irqfd: event_notifier_cleanup(&vdev->intx.unmask); fail: - qemu_set_fd_handler(irqfd.fd, vfio_intx_interrupt, NULL, vdev); + qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); #endif } @@ -178,12 +175,6 @@ fail: static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) { #ifdef CONFIG_KVM - struct kvm_irqfd irqfd =3D { - .fd =3D event_notifier_get_fd(&vdev->intx.interrupt), - .gsi =3D vdev->intx.route.irq, - .flags =3D KVM_IRQFD_FLAG_DEASSIGN, - }; - if (!vdev->intx.kvm_accel) { return; } @@ -197,7 +188,8 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) pci_irq_deassert(&vdev->pdev); =20 /* Tell KVM to stop listening for an INTx irqfd */ - if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) { + if (kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &vdev->intx.inter= rupt, + vdev->intx.route.irq)) { error_report("vfio: Error: Failed to disable INTx irqfd: %m"); } =20 @@ -205,7 +197,8 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) event_notifier_cleanup(&vdev->intx.unmask); =20 /* QEMU starts listening for interrupt events. */ - qemu_set_fd_handler(irqfd.fd, vfio_intx_interrupt, NULL, vdev); + qemu_set_fd_handler(event_notifier_get_fd(&vdev->intx.interrupt), + vfio_intx_interrupt, NULL, vdev); =20 vdev->intx.kvm_accel =3D false; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591906673; cv=none; d=zohomail.com; s=zohoarc; b=PiAqQpwSVeEzV7RKNcDCbVZ7cbBq8RjsQcdW1BzS3uWKK/vzxZJ+NOKX5g5ItyHvy4qX1Fa3bsHKoN9wZeSNWe24vGoiFtMkwWjiAMdYwSapQnFCW85gUqzUGLzIRkti7bYb3+fIsRPi8as/u37sc/bm/fSox8QiyGbiqWLdoWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906673; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xt61GIgecUTg5KOIYFEDCp0QNh8YsQUdYP2PYETJViQ=; b=Ogm50wE1z21HngxCNnUaTUrkJoZ000neG2sXhJXbTEQ7eJlEIO++3ESVyO/uiUYVwSOsAkAxkaqyj5aOwwRTHOEG1WsaGt08iMX6Fwakf0ESiwwWwI2CaRruziWC23IhLa0TpfE/pUvuLH9E8GSTocih1aqsZFPPj11XwqOKbNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906672995425.89057316122717; Thu, 11 Jun 2020 13:17:52 -0700 (PDT) Received: from localhost ([::1]:40924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTe3-0000mH-5Y for importer@patchew.org; Thu, 11 Jun 2020 16:17:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA5-0001I5-OI for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:53 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51571 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA4-0001Lf-1H for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-JnQ-1lthMLeq4o3ODd1V7w-1; Thu, 11 Jun 2020 15:46:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7275887300F for ; Thu, 11 Jun 2020 19:46:38 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32E4160CD3; Thu, 11 Jun 2020 19:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904811; 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=Xt61GIgecUTg5KOIYFEDCp0QNh8YsQUdYP2PYETJViQ=; b=gNu9rwMddAPXsP/+URV6mizoo4ksg0rtZSli9borzoLUfs8u/EZKmNdXUXFxo3x/kslcGl WX3Kmkb+3M36ug50g5/u83OR2tcm876vTFG5RswTV5UW+eyFX/9uE8LGKf5WA0Ery7d+ZZ hoefsypeAuBas14gl+wOufu8WNoW6Tc= X-MC-Unique: JnQ-1lthMLeq4o3ODd1V7w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 068/115] KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd Date: Thu, 11 Jun 2020 15:44:02 -0400 Message-Id: <20200611194449.31468-69-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Auger , Alex Williamson , Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu So that kvm_irqchip_assign_irqfd() can have access to the EventNotifiers, especially the resample event. It is needed in follow up patch to cache and kick resamplefds from QEMU. Reviewed-by: Eric Auger Reviewed-by: Alex Williamson Signed-off-by: Peter Xu Message-Id: <20200318145204.74483-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index d06cc04079..b048c10af9 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1662,9 +1662,13 @@ int kvm_irqchip_update_msi_route(KVMState *s, int vi= rq, MSIMessage msg, return kvm_update_routing_entry(s, &kroute); } =20 -static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int rfd, int virq, +static int kvm_irqchip_assign_irqfd(KVMState *s, EventNotifier *event, + EventNotifier *resample, int virq, bool assign) { + int fd =3D event_notifier_get_fd(event); + int rfd =3D resample ? event_notifier_get_fd(resample) : -1; + struct kvm_irqfd irqfd =3D { .fd =3D fd, .gsi =3D virq, @@ -1769,7 +1773,9 @@ int kvm_irqchip_add_hv_sint_route(KVMState *s, uint32= _t vcpu, uint32_t sint) return -ENOSYS; } =20 -static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool as= sign) +static int kvm_irqchip_assign_irqfd(KVMState *s, EventNotifier *event, + EventNotifier *resample, int virq, + bool assign) { abort(); } @@ -1783,15 +1789,13 @@ int kvm_irqchip_update_msi_route(KVMState *s, int v= irq, MSIMessage msg) int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, EventNotifier *rn, int virq) { - return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), - rn ? event_notifier_get_fd(rn) : -1, virq, true); + return kvm_irqchip_assign_irqfd(s, n, rn, virq, true); } =20 int kvm_irqchip_remove_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, int virq) { - return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), -1, virq, - false); + return kvm_irqchip_assign_irqfd(s, n, NULL, virq, false); } =20 int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591909016; cv=none; d=zohomail.com; s=zohoarc; b=O8w1Cw9vj2+gcW8M55gfi+9LxIfYZ5/II7D3Deuc/D89v3hZVx03OXj1Q/631mtT5DRl4w0/1p5NDhfI4OM/yv+yGTLjtBnExVXAk6hrP9V7MMqf7orIEQAbVA1iqloDNTb+cugbVaBg38n0QXqnKhSd9gSTWkGFS6ba0hvchuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909016; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VOlDszRVFFz87rfQJWUx9nl1C9JGDSXdw5TCSqdQv1E=; b=ZtzshX5TYuYDrCxcE0AOc6BqTzwuWF+dq35BP+RzQiPZGn13HXO1tPNJaMo/UFlYFn6wWFzL0b45uMWc7/kcsAXwUaUYS0k/g4rR/PuEeSQxd+D1IBnjkUxBXJlGw9KABLVVKnpdN60D2BFxiUGq2KTO6vhFyN3e7UoQMSCxBaE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591909016403483.4466242817987; Thu, 11 Jun 2020 13:56:56 -0700 (PDT) Received: from localhost ([::1]:34832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUFq-00009M-MZ for importer@patchew.org; Thu, 11 Jun 2020 16:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAG-0001bt-RL for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55700 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAE-0001OA-5l for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-nUN0LumTMj6ZOw1sSstVag-1; Thu, 11 Jun 2020 15:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4219107ACCA for ; Thu, 11 Jun 2020 19:46:43 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86F236840E; Thu, 11 Jun 2020 19:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904821; 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=VOlDszRVFFz87rfQJWUx9nl1C9JGDSXdw5TCSqdQv1E=; b=c+SJHO2FR9Sbh5pwQQDbofBXhBKWVKXHdUzKD3StfMBQhXX8p8aRaldighQ6HsZbnx+nrQ XRsj++3VaGMg7oRNeZN2UUY9XmE9DeRY58hAZAqqKNL1ECDJ2Fxx1G09Ju+fEQIMJR78uT fCL4dPhY8N7FnLM2nDOx5DE8z3MZzsQ= X-MC-Unique: nUN0LumTMj6ZOw1sSstVag-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 069/115] KVM: Kick resamplefd for split kernel irqchip Date: Thu, 11 Jun 2020 15:44:03 -0400 Message-Id: <20200611194449.31468-70-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Peter Xu This is majorly only for X86 because that's the only one that supports split irqchip for now. When the irqchip is split, we face a dilemma that KVM irqfd will be enabled, however the slow irqchip is still running in the userspace. It means that the resamplefd in the kernel irqfds won't take any effect and it will miss to ack INTx interrupts on EOIs. One example is split irqchip with VFIO INTx, which will break if we use the VFIO INTx fast path. This patch can potentially supports the VFIO fast path again for INTx, that the IRQ delivery will still use the fast path, while we don't need to trap MMIOs in QEMU for the device to emulate the EIOs (see the callers of vfio_eoi() hook). However the EOI of the INTx will still need to be done from the userspace by caching all the resamplefds in QEMU and kick properly for IOAPIC EOI broadcast. This is tricky because in this case the userspace ioapic irr & remote-irr will be bypassed. However such a change will greatly boost performance for assigned devices using INTx irqs (TCP_RR boosts 46% after this patch applied). When the userspace is responsible for the resamplefd kickup, don't register it on the kvm_irqfd anymore, because on newer kernels (after commit 654f1f13ea56, 5.2+) the KVM_IRQFD will fail if with both split irqchip and resamplefd. This will make sure that the fast path will work for all supported kernels. https://patchwork.kernel.org/patch/10738541/#22609933 Suggested-by: Paolo Bonzini Signed-off-by: Peter Xu Message-Id: <20200318145204.74483-5-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 79 ++++++++++++++++++++++++++++++++++++++++-- accel/kvm/trace-events | 1 + hw/intc/ioapic.c | 19 ++++++++++ include/sysemu/kvm.h | 4 +++ 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b048c10af9..f24d7da783 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -160,9 +160,59 @@ static const KVMCapabilityInfo kvm_required_capabilite= s[] =3D { static NotifierList kvm_irqchip_change_notifiers =3D NOTIFIER_LIST_INITIALIZER(kvm_irqchip_change_notifiers); =20 +struct KVMResampleFd { + int gsi; + EventNotifier *resample_event; + QLIST_ENTRY(KVMResampleFd) node; +}; +typedef struct KVMResampleFd KVMResampleFd; + +/* + * Only used with split irqchip where we need to do the resample fd + * kick for the kernel from userspace. + */ +static QLIST_HEAD(, KVMResampleFd) kvm_resample_fd_list =3D + QLIST_HEAD_INITIALIZER(kvm_resample_fd_list); + #define kvm_slots_lock(kml) qemu_mutex_lock(&(kml)->slots_lock) #define kvm_slots_unlock(kml) qemu_mutex_unlock(&(kml)->slots_lock) =20 +static inline void kvm_resample_fd_remove(int gsi) +{ + KVMResampleFd *rfd; + + QLIST_FOREACH(rfd, &kvm_resample_fd_list, node) { + if (rfd->gsi =3D=3D gsi) { + QLIST_REMOVE(rfd, node); + g_free(rfd); + break; + } + } +} + +static inline void kvm_resample_fd_insert(int gsi, EventNotifier *event) +{ + KVMResampleFd *rfd =3D g_new0(KVMResampleFd, 1); + + rfd->gsi =3D gsi; + rfd->resample_event =3D event; + + QLIST_INSERT_HEAD(&kvm_resample_fd_list, rfd, node); +} + +void kvm_resample_fd_notify(int gsi) +{ + KVMResampleFd *rfd; + + QLIST_FOREACH(rfd, &kvm_resample_fd_list, node) { + if (rfd->gsi =3D=3D gsi) { + event_notifier_set(rfd->resample_event); + trace_kvm_resample_fd_notify(gsi); + return; + } + } +} + int kvm_get_max_memslots(void) { KVMState *s =3D KVM_STATE(current_accel()); @@ -1676,8 +1726,33 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, Eve= ntNotifier *event, }; =20 if (rfd !=3D -1) { - irqfd.flags |=3D KVM_IRQFD_FLAG_RESAMPLE; - irqfd.resamplefd =3D rfd; + assert(assign); + if (kvm_irqchip_is_split()) { + /* + * When the slow irqchip (e.g. IOAPIC) is in the + * userspace, KVM kernel resamplefd will not work because + * the EOI of the interrupt will be delivered to userspace + * instead, so the KVM kernel resamplefd kick will be + * skipped. The userspace here mimics what the kernel + * provides with resamplefd, remember the resamplefd and + * kick it when we receive EOI of this IRQ. + * + * This is hackery because IOAPIC is mostly bypassed + * (except EOI broadcasts) when irqfd is used. However + * this can bring much performance back for split irqchip + * with INTx IRQs (for VFIO, this gives 93% perf of the + * full fast path, which is 46% perf boost comparing to + * the INTx slow path). + */ + kvm_resample_fd_insert(virq, resample); + } else { + irqfd.flags |=3D KVM_IRQFD_FLAG_RESAMPLE; + irqfd.resamplefd =3D rfd; + } + } else if (!assign) { + if (kvm_irqchip_is_split()) { + kvm_resample_fd_remove(virq); + } } =20 if (!kvm_irqfds_enabled()) { diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index 4fb6e59d19..a68eb66534 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -16,4 +16,5 @@ kvm_set_ioeventfd_mmio(int fd, uint64_t addr, uint32_t va= l, bool assign, uint32_ kvm_set_ioeventfd_pio(int fd, uint16_t addr, uint32_t val, bool assign, ui= nt32_t size, bool datamatch) "fd: %d @0x%x val=3D0x%x assign: %d size: %d m= atch: %d" kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_add= r, uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags= =3D0x%x gpa=3D0x%"PRIx64 " size=3D0x%"PRIx64 " ua=3D0x%"PRIx64 " ret=3D%d" kvm_clear_dirty_log(uint32_t slot, uint64_t start, uint32_t size) "slot#%"= PRId32" start 0x%"PRIx64" size 0x%"PRIx32 +kvm_resample_fd_notify(int gsi) "gsi %d" =20 diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index ffe30dc457..bca71b5934 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -241,6 +241,25 @@ void ioapic_eoi_broadcast(int vector) continue; } =20 +#ifdef CONFIG_KVM + /* + * When IOAPIC is in the userspace while APIC is still in + * the kernel (i.e., split irqchip), we have a trick to + * kick the resamplefd logic for registered irqfds from + * userspace to deactivate the IRQ. When that happens, it + * means the irq bypassed userspace IOAPIC (so the irr and + * remote-irr of the table entry should be bypassed too + * even if interrupt come). Still kick the resamplefds if + * they're bound to the IRQ, to make sure to EOI the + * interrupt for the hardware correctly. + * + * Note: We still need to go through the irr & remote-irr + * operations below because we don't know whether there're + * emulated devices that are using/sharing the same IRQ. + */ + kvm_resample_fd_notify(n); +#endif + if (!(entry & IOAPIC_LVT_REMOTE_IRR)) { continue; } diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 3b2250471c..b4174d941c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -554,4 +554,8 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *so= urce); int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target); struct ppc_radix_page_info *kvm_get_radix_page_info(void); int kvm_get_max_memslots(void); + +/* Notify resamplefd for EOI of specific interrupts. */ +void kvm_resample_fd_notify(int gsi); + #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908044; cv=none; d=zohomail.com; s=zohoarc; b=KzpAtIsANMvSVPuaM7TD1c3OJdtx8QwudwjNyE+OzeDxtlYUL5v7IAsVoRqkoWzK6S6ljYFg6zisAxivL4T/cQVuEjoXBC7rMPz6pc/DCSoJ1rJSRPHws33akQO5Dry5sp1OYkExT16zp3pagX5bi6YGtZq7aRaHFg5divu0cyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908044; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DCsNk6O2BBst3KYCL9PdkLrI3ixjpMCThmPZ1p8h97c=; b=lUaFUuvcaoBeFrE1e9C3zJCumSQcL49OtME9PmaM5CMX5eRI0sSHtqz42HntIsb3z99TIEKFvldOhNK8DtCUVRASD8qxBs1gxBSQ53R+dW1SGUTHNaAHeDvh5Ce+qBAdxaxJGwqS+DbZhdQ2op0bIc3Ncg0Xmn8J6ltdhLB8VMg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908044093534.3653727913957; Thu, 11 Jun 2020 13:40:44 -0700 (PDT) Received: from localhost ([::1]:38218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU0A-0006H4-Kd for importer@patchew.org; Thu, 11 Jun 2020 16:40:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA3-0001Ef-AP for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20489 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA1-0001LM-JU for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-RF9ftbvkONuhfUmxI-fPeA-1; Thu, 11 Jun 2020 15:46:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0976E1005513; Thu, 11 Jun 2020 19:46:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E17860CC0; Thu, 11 Jun 2020 19:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904809; 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=DCsNk6O2BBst3KYCL9PdkLrI3ixjpMCThmPZ1p8h97c=; b=Nmfq7lofVNwAdUxCt8vJ06zKr0JNPT1+PQvf5rjlN7STzB0Y53MEgWgX4IF8o914EQMawO LrLAZIvw9/BLYyBOpc+JPPD0pOncX0A3RTLovkcVuosJVShibQ1/qNkdPtTTYHBMKujyLw Rim6AELxJHOUESMl6DlnVk5QmESl+2Y= X-MC-Unique: RF9ftbvkONuhfUmxI-fPeA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 070/115] chardev/char-socket: Properly make qio connections non blocking Date: Thu, 11 Jun 2020 15:44:04 -0400 Message-Id: <20200611194449.31468-71-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sai Pavan Boddu , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sai Pavan Boddu In tcp_chr_sync_read function, there is a possibility of socket disconnection during blocking read, then tcp_chr_hup function would clean up the qio channel pointers(i.e ioc, sioc). Signed-off-by: Sai Pavan Boddu Message-Id: <1587289900-29485-1-git-send-email-sai.pavan.boddu@xilinx.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- chardev/char-socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index db253d4024..dd3d3ed8d6 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -550,7 +550,9 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_= t *buf, int len) =20 qio_channel_set_blocking(s->ioc, true, NULL); size =3D tcp_chr_recv(chr, (void *) buf, len); - qio_channel_set_blocking(s->ioc, false, NULL); + if (s->state !=3D TCP_CHARDEV_STATE_DISCONNECTED) { + qio_channel_set_blocking(s->ioc, false, NULL); + } if (size =3D=3D 0) { /* connection closed */ tcp_chr_disconnect(chr); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907806; cv=none; d=zohomail.com; s=zohoarc; b=kXR1gjz152THu+t18do+H+q+BKUpTvbOsdIZMo4fR014VBtb13w0u4NzqbJTr9eBY/ZY3eVQmHWQuCx8Nf/+rGysNSMGGKdKZeLRrtWg9P8FjhxTxGG4KzwoafslpRRMIYTaXN6+KyCYI0BSXRTidWmCAiQXNJfB650EoQKzSdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LPB2CEdAH2eBhJn+rk8T9Y/aaFkfHqAa/A8gAWOEfA8=; b=mww2YwGhCW1idVp2QaPf2TgoG4O4uuWmvfCUhgHQH83pQmz/sxZY9yWiT6Efkxy6xqUYWGXZQr1QFv2xL/wdsQUjP3y4/m1wxAii/3wYYu+z6rlNWiuhK+zU+oMGrBdCr8MUFJVdCTu4xRwQ3ZUx6im2exkI3e934uwXa8vFSH0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907806473212.34012999143727; Thu, 11 Jun 2020 13:36:46 -0700 (PDT) Received: from localhost ([::1]:50890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTwL-0007Bi-5I for importer@patchew.org; Thu, 11 Jun 2020 16:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAC-0001Ta-4A for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:00 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52157 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAA-0001Mv-66 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-WzmfWEFUNim0xjBzJ0t_5w-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89FDC107ACF8; Thu, 11 Jun 2020 19:46:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3094C60CC0; Thu, 11 Jun 2020 19:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904817; 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=LPB2CEdAH2eBhJn+rk8T9Y/aaFkfHqAa/A8gAWOEfA8=; b=f0MPSjWScjRbCquyCwLkzHcg/U+vT3lW/a6CKadKiUBruiUmEzq2BM0UmaTSJRvxOlYaG2 Fx7D8dU+5OMMam+sGqCbd+IrLV0YHpeCDtmLrvhIZE3HLGg4Gc6WfvDD35WgVE+uehLoiM cwIMemjk1yR9fYEDQ2JUYo6im4PXyxE= X-MC-Unique: WzmfWEFUNim0xjBzJ0t_5w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 071/115] tests: machine-none-test: Enable MicroBlaze testing Date: Thu, 11 Jun 2020 15:44:05 -0400 Message-Id: <20200611194449.31468-72-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E. Iglesias" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" Enable MicroBlaze testing. Signed-off-by: Edgar E. Iglesias Message-Id: <20200416193303.23674-2-edgar.iglesias@gmail.com> Signed-off-by: Paolo Bonzini --- tests/qtest/machine-none-test.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/qtest/machine-none-test.c b/tests/qtest/machine-none-tes= t.c index 10d8ec26a9..8b7abea8af 100644 --- a/tests/qtest/machine-none-test.c +++ b/tests/qtest/machine-none-test.c @@ -33,8 +33,8 @@ static struct arch2cpu cpus_map[] =3D { { "cris", "crisv32" }, { "lm32", "lm32-full" }, { "m68k", "m5206" }, - /* FIXME: { "microblaze", "any" }, doesn't work with -M none -cpu any = */ - /* FIXME: { "microblazeel", "any" }, doesn't work with -M none -cpu an= y */ + { "microblaze", "any" }, + { "microblazeel", "any" }, { "mips", "4Kc" }, { "mipsel", "I7200" }, { "mips64", "20Kc" }, @@ -79,10 +79,8 @@ static void test_machine_cpu_cli(void) QTestState *qts; =20 if (!cpu_model) { - if (!(!strcmp(arch, "microblaze") || !strcmp(arch, "microblazeel")= )) { - fprintf(stderr, "WARNING: cpu name for target '%s' isn't defin= ed," - " add it to cpus_map\n", arch); - } + fprintf(stderr, "WARNING: cpu name for target '%s' isn't defined," + " add it to cpus_map\n", arch); return; /* TODO: die here to force all targets have a test */ } qts =3D qtest_initf("-machine none -cpu '%s'", cpu_model); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907668; cv=none; d=zohomail.com; s=zohoarc; b=TwChD2M4tMFNZWkpPrhbNcpwQz0MrIiDe3QITSeGN71GPj8JR0BCCv4NS5CYCvwYNODL6QvF3jQbXtaHU/+b/nSRN3sReaNcczQ5aC7vLLJFLz8MImkG6+mmdL6797/Hsbw2nL1qYS6Uvy406Ms0aa+gHzH9/KxnjFvfFVHZfaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907668; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F81J/ZRp0YOpkDwfZ6abXb/SMvXJi0mCgUnRO82JJ0A=; b=lSkyg49nAzO3fMu7euPLAxNpb7+KW1AsME9hyRW1SkSPIaiJmoFj2Joy9G/ztpQWFIZpiRqxa+qQjY1p51WuLTS91wfSJk/5GsLl/2zXooMnYxcUz4/Gb8njLsh1ZmveJP8cU6IU9jNDv9UzkdOffxQNVZ7mYlGW4opl4t2Ky4g= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907668451800.560033162078; Thu, 11 Jun 2020 13:34:28 -0700 (PDT) Received: from localhost ([::1]:42666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTu6-0002kk-1G for importer@patchew.org; Thu, 11 Jun 2020 16:34:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA3-0001F4-Lm for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:52 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55704 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA1-0001LR-Si for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-n7l9T1rvOumJbNpS-2jgzw-1; Thu, 11 Jun 2020 15:46:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C9541005512; Thu, 11 Jun 2020 19:46:46 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0D6660CC0; Thu, 11 Jun 2020 19:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904809; 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=F81J/ZRp0YOpkDwfZ6abXb/SMvXJi0mCgUnRO82JJ0A=; b=aVXEa1wqKssPrZqFwBQ4HtqICC2MTefQ90TMBaA2XVy4FQTrgWu8eba9V6Xe+N4VPK1lZk TuVjOy+pUGsn8Bmo/6lM1A6ET3ecT+Pbp84/LiTUEsNtqMUuMCJfSCUyelfZdG7SGzkjSH 6kZtbZbg1/9YOUjByAYScujy9dPDcME= X-MC-Unique: n7l9T1rvOumJbNpS-2jgzw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 072/115] hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands Date: Thu, 11 Jun 2020 15:44:06 -0400 Message-Id: <20200611194449.31468-73-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Huang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Wei Huang Many reserved bits of amd_iommu commands are defined incorrectly in QEMU. Because of it, QEMU incorrectly injects lots of illegal commands into guest VM's IOMMU event log. Signed-off-by: Wei Huang Message-Id: <20200418042845.596457-1-wei.huang2@amd.com> Signed-off-by: Paolo Bonzini --- hw/i386/amd_iommu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index fd75cae024..4346060e62 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -370,7 +370,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64= _t *cmd) hwaddr addr =3D cpu_to_le64(extract64(cmd[0], 3, 49)) << 3; uint64_t data =3D cpu_to_le64(cmd[1]); =20 - if (extract64(cmd[0], 51, 8)) { + if (extract64(cmd[0], 52, 8)) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); } @@ -395,7 +395,7 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uin= t64_t *cmd) uint16_t devid =3D cpu_to_le16((uint16_t)extract64(cmd[0], 0, 16)); =20 /* This command should invalidate internal caches of which there isn't= */ - if (extract64(cmd[0], 15, 16) || cmd[1]) { + if (extract64(cmd[0], 16, 44) || cmd[1]) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); } @@ -405,9 +405,9 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uin= t64_t *cmd) =20 static void amdvi_complete_ppr(AMDVIState *s, uint64_t *cmd) { - if (extract64(cmd[0], 15, 16) || extract64(cmd[0], 19, 8) || + if (extract64(cmd[0], 16, 16) || extract64(cmd[0], 52, 8) || extract64(cmd[1], 0, 2) || extract64(cmd[1], 3, 29) - || extract64(cmd[1], 47, 16)) { + || extract64(cmd[1], 48, 16)) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); } @@ -438,8 +438,8 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *= cmd) { uint16_t domid =3D cpu_to_le16((uint16_t)extract64(cmd[0], 32, 16)); =20 - if (extract64(cmd[0], 20, 12) || extract64(cmd[0], 16, 12) || - extract64(cmd[0], 3, 10)) { + if (extract64(cmd[0], 20, 12) || extract64(cmd[0], 48, 12) || + extract64(cmd[1], 3, 9)) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); } @@ -451,7 +451,7 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *= cmd) =20 static void amdvi_prefetch_pages(AMDVIState *s, uint64_t *cmd) { - if (extract64(cmd[0], 16, 8) || extract64(cmd[0], 20, 8) || + if (extract64(cmd[0], 16, 8) || extract64(cmd[0], 52, 8) || extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 1) || extract64(cmd[1], 5, 7)) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), @@ -463,7 +463,7 @@ static void amdvi_prefetch_pages(AMDVIState *s, uint64_= t *cmd) =20 static void amdvi_inval_inttable(AMDVIState *s, uint64_t *cmd) { - if (extract64(cmd[0], 16, 16) || cmd[1]) { + if (extract64(cmd[0], 16, 44) || cmd[1]) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); return; @@ -479,7 +479,8 @@ static void iommu_inval_iotlb(AMDVIState *s, uint64_t *= cmd) { =20 uint16_t devid =3D extract64(cmd[0], 0, 16); - if (extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 9)) { + if (extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 1) || + extract64(cmd[1], 6, 6)) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); return; --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908093; cv=none; d=zohomail.com; s=zohoarc; b=IRRVoThhSKQgoQmXDLWL2XeCZoN5JCoCeNYm8iFNLehQQ01/+EsP78fO10YE5q4CoBO2xpTpV5R30BjRwBt+efR9YpO+FOlltYtlwJRCf9xl4sVyfBba9YgcSuUAwnEXz9liUZp4B9/ragjRhHj8R7o54JTbdt9s6/p0BjZ81vI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908093; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zYBTb0M0ZA3DWZb/MQ7k4GbYqnZpIJsslP+QwLOSIHU=; b=e30H7/mSgi9+Qr5yN6FwndvcB1d+RrMaiaJO0Nwc0Bnf0EYTo4sSLMaGXKmQUeOqVqFVU6mP6isxAUJdGmVAX0s266r3TvC96CSgpWmtlo9+Wf64kAabDzub/tBupxuvHY9pkgaAOrFbmqPM964JsHGHGX6yWeAP7MvcPM/yCBw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908093070753.7273796715399; Thu, 11 Jun 2020 13:41:33 -0700 (PDT) Received: from localhost ([::1]:40424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU0x-0007Q4-PC for importer@patchew.org; Thu, 11 Jun 2020 16:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAX-00026x-55 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:21 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51913 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAP-0001Qm-Tg for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-HMnhUwunPMKZjlxQ9QCHJA-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC0E7107AD9A; Thu, 11 Jun 2020 19:46:46 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43DA060CC0; Thu, 11 Jun 2020 19:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904833; 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=zYBTb0M0ZA3DWZb/MQ7k4GbYqnZpIJsslP+QwLOSIHU=; b=ipGBGsmvcklcMn56ay1qUKvZQXMoZUwLYMLPnS804DUtzJwITSnv2GTAeeGI0txel3oQST qx0b0yzmQo0E0/dUszthJLarm+8yhzy+qb67iO2SCpH6ESXFIxgKipL9r7NShq1dXFXEY1 AXuI7UfrLxX/DcBYmh1AvfvslQYAf8Q= X-MC-Unique: HMnhUwunPMKZjlxQ9QCHJA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 073/115] replay: implement fair mutex Date: Thu, 11 Jun 2020 15:44:07 -0400 Message-Id: <20200611194449.31468-74-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Dovgalyuk , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk In record/replay icount mode main loop thread and vCPU thread do not perform simultaneously. They take replay mutex to synchronize the actions. Sometimes vCPU thread waits for locking the mutex for very long time, because main loop releases the mutex and takes it back again. Standard qemu mutex do not provide the ordering capabilities. This patch adds a "queue" for replay mutex. Therefore thread ordering becomes more "fair". Threads are executed in the same order as they are trying to take the mutex. Signed-off-by: Pavel Dovgalyuk Message-Id: <158823802979.28101.9340462887738957616.stgit@pasha-ThinkPad-X2= 80> Signed-off-by: Paolo Bonzini --- replay/replay-internal.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index eba8246aae..2e8a3e947a 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -22,6 +22,9 @@ It also protects replay events queue which stores events to be written or read to the log. */ static QemuMutex lock; +/* Condition and queue for fair ordering of mutex lock requests. */ +static QemuCond mutex_cond; +static unsigned long mutex_head, mutex_tail; =20 /* File for replay writing */ static bool write_error; @@ -197,9 +200,10 @@ static __thread bool replay_locked; void replay_mutex_init(void) { qemu_mutex_init(&lock); + qemu_cond_init(&mutex_cond); /* Hold the mutex while we start-up */ - qemu_mutex_lock(&lock); replay_locked =3D true; + ++mutex_tail; } =20 bool replay_mutex_locked(void) @@ -211,10 +215,16 @@ bool replay_mutex_locked(void) void replay_mutex_lock(void) { if (replay_mode !=3D REPLAY_MODE_NONE) { + unsigned long id; g_assert(!qemu_mutex_iothread_locked()); g_assert(!replay_mutex_locked()); qemu_mutex_lock(&lock); + id =3D mutex_tail++; + while (id !=3D mutex_head) { + qemu_cond_wait(&mutex_cond, &lock); + } replay_locked =3D true; + qemu_mutex_unlock(&lock); } } =20 @@ -222,7 +232,10 @@ void replay_mutex_unlock(void) { if (replay_mode !=3D REPLAY_MODE_NONE) { g_assert(replay_mutex_locked()); + qemu_mutex_lock(&lock); + ++mutex_head; replay_locked =3D false; + qemu_cond_broadcast(&mutex_cond); qemu_mutex_unlock(&lock); } } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906939; cv=none; d=zohomail.com; s=zohoarc; b=Gi4Hgk2MjE/j10FXeQHPevp+Hak/ydLyMoRAIgZ21KyEhD4bFOr+MTsN31lATFVLCoiPagACKhYWCN/OjZVC56vVKgZuLAclrPSjyAanqN4f+ThLa3j/QNZfIAM6QrR48SMeXofg+tWfS23yC/Jjk0mXOwKUqUBWnpBZVO3MUNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906939; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+2+m6rN7Zl+Pne0W6SURoqqxLTIDqqxuGgYBzulALHk=; b=DGY2HpvfmMTKpNxfXzUOO3TmNC/rE/GMy8k2ryeoRxMsXIqFFwqyQlBuELSwxNie1kHQiPOmEQ10dWKdmxLe4vBYjSbhwXs/VW9DAoNhwJwvsymrRRK0oNRiB0ObQ39C/SQQHDuj83qHk9Ds5rD6l5S8s8uT1EXRHAOjaMNB5c4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906939750948.1145823185046; Thu, 11 Jun 2020 13:22:19 -0700 (PDT) Received: from localhost ([::1]:57710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTiM-0000Pm-Ge for importer@patchew.org; Thu, 11 Jun 2020 16:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAB-0001S8-3r for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:59 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:37690 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA9-0001Mb-6r for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-Ixpys1EpMiKFKZzLcUUF_w-1; Thu, 11 Jun 2020 15:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47F8783DB79; Thu, 11 Jun 2020 19:46:47 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E34C760CC0; Thu, 11 Jun 2020 19:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904816; 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=+2+m6rN7Zl+Pne0W6SURoqqxLTIDqqxuGgYBzulALHk=; b=WSumNeU6PGAOzn3E+QXNMX7uZwX26vAyD3L5HWhxYIFxixynHOwVSQTI2j2dvPxDfaeRNp 0gQoFnCtcwx5uGLttCrx27xq573IbRFVc1gx+Ra3kC/wpAAtHnC5MsgfnuaLqw/BAaAKkq ywSG3aJIpugtz0v+DeLqiCLQ2N3FsYE= X-MC-Unique: Ixpys1EpMiKFKZzLcUUF_w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 074/115] i386: Remove unused define's from hax and hvf Date: Thu, 11 Jun 2020 15:44:08 -0400 Message-Id: <20200611194449.31468-75-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julio Faracco Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Julio Faracco Commit acb9f95a removed boundary checks for ID and VCPU ID. After that, the max definitions of that boundaries are not required anymore. This commit is only a code cleanup. Signed-off-by: Julio Faracco Message-Id: <20200323200538.202164-1-jcfaracco@gmail.com> Signed-off-by: Paolo Bonzini --- target/i386/hax-i386.h | 2 -- target/i386/hvf/hvf-i386.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/target/i386/hax-i386.h b/target/i386/hax-i386.h index 7d988f81da..ec28708185 100644 --- a/target/i386/hax-i386.h +++ b/target/i386/hax-i386.h @@ -41,8 +41,6 @@ struct hax_state { }; =20 #define HAX_MAX_VCPU 0x10 -#define MAX_VM_ID 0x40 -#define MAX_VCPU_ID 0x40 =20 struct hax_vm { hax_fd fd; diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h index 15ee4835cf..fbe4a350c5 100644 --- a/target/i386/hvf/hvf-i386.h +++ b/target/i386/hvf/hvf-i386.h @@ -21,8 +21,6 @@ #include "x86.h" =20 #define HVF_MAX_VCPU 0x10 -#define MAX_VM_ID 0x40 -#define MAX_VCPU_ID 0x40 =20 extern struct hvf_state hvf_global; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907365; cv=none; d=zohomail.com; s=zohoarc; b=Zy6kEPqWLRCkff4nzzYk8uV1AWGPL7xsGcGKeWMSz23Wz1Spv3qzcgb3CCMuXpRrNKqkcuvaO4J75zgYgVXHqClYYuyP+42ZyxOvXsrd3dUd10lpnDdWXHL/Y+itHuho6YqIaKw1JB8Rxbqf2a379rTPFY2YNrqeOcEn9kx0ep4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907365; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eOCmrAmGxQCiphXmXYzrnQMo7oAMTlydx7QpNksXJw0=; b=gb+AnWY3gHbwW1tGC1nSMiVPGL4bdcOTIRE05/V4JXtPsgGWqgrPZI6eIsYsuYobYDtrrpD+QQvTxE4j6RaMYFXWQkS3/PtRVUUEj+zDYc+5WjEyfygKLTg1NBhKJ+13np56VshzFh0BIIsAmbdEo8iPAMJl51yW1Gj3nT9zBx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919073659521010.9461829529041; Thu, 11 Jun 2020 13:29:25 -0700 (PDT) Received: from localhost ([::1]:55980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTpD-0004Eh-B9 for importer@patchew.org; Thu, 11 Jun 2020 16:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAA-0001QV-2x for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57275 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA7-0001M9-NY for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-Sff3GHm-NzWV7pti8d8OLw-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16E4C91165; Thu, 11 Jun 2020 19:46:48 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F45860CC0; Thu, 11 Jun 2020 19:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904815; 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=eOCmrAmGxQCiphXmXYzrnQMo7oAMTlydx7QpNksXJw0=; b=cyWq9nbEm7XMnvZakHwchi5cRv7rGK3ImBZK2Ji0gDiKzV17i6Wab1PadG482KdM2i5G1P +U6Yk+svcOpfOdMgn4vgjT9qR7jteCHkzFOFMAQg9JBmh+yJr/6IL3JufeHUo9QxLbjmSg oFSYp71Xr2FCkbL7/y0F++BuGYOUrmA= X-MC-Unique: Sff3GHm-NzWV7pti8d8OLw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 075/115] target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES Date: Thu, 11 Jun 2020 15:44:09 -0400 Message-Id: <20200611194449.31468-76-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcelo Tosatti , Eduardo Habkost , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Like Xu The Perfmon and Debug Capability MSR named IA32_PERF_CAPABILITIES is a feature-enumerating MSR, which only enumerates the feature full-width write (via bit 13) by now which indicates the processor supports IA32_A_PMCx interface for updating bits 32 and above of IA32_PMCx. The existence of MSR IA32_PERF_CAPABILITIES is enumerated by CPUID.1:ECX[15= ]. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcelo Tosatti Cc: qemu-devel@nongnu.org Signed-off-by: Like Xu Message-Id: <20200529074347.124619-5-like.xu@linux.intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 23 +++++++++++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e89d9fa894..2d3b8d5dea 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1139,6 +1139,22 @@ static FeatureWordInfo feature_word_info[FEATURE_WOR= DS] =3D { .index =3D MSR_IA32_CORE_CAPABILITY, }, }, + [FEAT_PERF_CAPABILITIES] =3D { + .type =3D MSR_FEATURE_WORD, + .feat_names =3D { + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, "full-width-write", NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .msr =3D { + .index =3D MSR_IA32_PERF_CAPABILITIES, + }, + }, =20 [FEAT_VMX_PROCBASED_CTLS] =3D { .type =3D MSR_FEATURE_WORD, @@ -1316,6 +1332,10 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_0_EDX, CPUID_7_0_EDX_CORE_CAPABILIT= Y }, .to =3D { FEAT_CORE_CAPABILITY, ~0ull }, }, + { + .from =3D { FEAT_1_ECX, CPUID_EXT_PDCM }, + .to =3D { FEAT_PERF_CAPABILITIES, ~0ull }, + }, { .from =3D { FEAT_1_ECX, CPUID_EXT_VMX }, .to =3D { FEAT_VMX_PROCBASED_CTLS, ~0ull }, @@ -5488,6 +5508,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *ebx |=3D (cs->nr_cores * cs->nr_threads) << 16; *edx |=3D CPUID_HT; } + if (!cpu->enable_pmu) { + *ecx &=3D ~CPUID_EXT_PDCM; + } break; case 2: /* cache info: needed for Pentium Pro compatibility */ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 100476ee89..c2b8bdcbde 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -356,6 +356,8 @@ typedef enum X86Seg { #define MSR_IA32_ARCH_CAPABILITIES 0x10a #define ARCH_CAP_TSX_CTRL_MSR (1<<7) =20 +#define MSR_IA32_PERF_CAPABILITIES 0x345 + #define MSR_IA32_TSX_CTRL 0x122 #define MSR_IA32_TSCDEADLINE 0x6e0 =20 @@ -529,6 +531,7 @@ typedef enum FeatureWord { FEAT_XSAVE_COMP_HI, /* CPUID[EAX=3D0xd,ECX=3D0].EDX */ FEAT_ARCH_CAPABILITIES, FEAT_CORE_CAPABILITY, + FEAT_PERF_CAPABILITIES, FEAT_VMX_PROCBASED_CTLS, FEAT_VMX_SECONDARY_CTLS, FEAT_VMX_PINBASED_CTLS, diff --git a/target/i386/kvm.c b/target/i386/kvm.c index ef2e0a81dd..b3c13cb898 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -110,6 +110,7 @@ static bool has_msr_core_capabs; static bool has_msr_vmx_vmfunc; static bool has_msr_ucode_rev; static bool has_msr_vmx_procbased_ctls2; +static bool has_msr_perf_capabs; =20 static uint32_t has_architectural_pmu_version; static uint32_t num_architectural_pmu_gp_counters; @@ -2033,6 +2034,9 @@ static int kvm_get_supported_msrs(KVMState *s) case MSR_IA32_CORE_CAPABILITY: has_msr_core_capabs =3D true; break; + case MSR_IA32_PERF_CAPABILITIES: + has_msr_perf_capabs =3D true; + break; case MSR_IA32_VMX_VMFUNC: has_msr_vmx_vmfunc =3D true; break; @@ -2649,6 +2653,18 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, Featu= reWordArray f) VMCS12_MAX_FIELD_INDEX << 1); } =20 +static void kvm_msr_entry_add_perf(X86CPU *cpu, FeatureWordArray f) +{ + uint64_t kvm_perf_cap =3D + kvm_arch_get_supported_msr_feature(kvm_state, + MSR_IA32_PERF_CAPABILITIES); + + if (kvm_perf_cap) { + kvm_msr_entry_add(cpu, MSR_IA32_PERF_CAPABILITIES, + kvm_perf_cap & f[FEAT_PERF_CAPABILITIES]); + } +} + static int kvm_buf_set_msrs(X86CPU *cpu) { int ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf); @@ -2681,6 +2697,10 @@ static void kvm_init_msrs(X86CPU *cpu) env->features[FEAT_CORE_CAPABILITY]); } =20 + if (has_msr_perf_capabs && cpu->enable_pmu) { + kvm_msr_entry_add_perf(cpu, env->features); + } + if (has_msr_ucode_rev) { kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev); } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907252; cv=none; d=zohomail.com; s=zohoarc; b=LKtSYumpJy81FpsNwv3yZoMfAVcTr4i8jTU6VK4fg3cLFdNoqI/+GPwTeumYndnmNQMsb/TbB7Pzyq0C8qZhuyVpd5G0RqCxnGS4w1ZlO7R7QPx43Kyi9aZMd6URo5U8GO0WfOI0biwR6+kdKYwHocmj+Uwrdj8WuZxWrP5vVXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907252; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CmnoTWG/btVuCmK6Ik7UOefkyk2LvbJKaqZOS4PyRXs=; b=GGtuYqcJeHuCF7zTlDtoDmLitmST8fyYeKYu8Cahmw7Xt0YWlBpDzzzmZPtZzEEVNZxe41PBgHHssZeuQpqhmplIvlkfzk4JV+ANrOzC8dbZQ0IPAASOXg1u58ueP2wNHdSrsxuEqGUXMnS9jdPLjTpsP1nZv/wyIPiMV+b0DDY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907252513916.0038735588588; Thu, 11 Jun 2020 13:27:32 -0700 (PDT) Received: from localhost ([::1]:47718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTnP-0000XQ-5D for importer@patchew.org; Thu, 11 Jun 2020 16:27:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA9-0001Ou-5f for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:57 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41606 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA7-0001M4-EU for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-EpW8h2KiOeujYIFYA0AugA-1; Thu, 11 Jun 2020 15:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9777C1940920; Thu, 11 Jun 2020 19:46:48 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DD1560E3E; Thu, 11 Jun 2020 19:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904814; 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=CmnoTWG/btVuCmK6Ik7UOefkyk2LvbJKaqZOS4PyRXs=; b=PR+yR1z9rI5aRgWY3iXHvj+6OJQHRFcRvQrMgvrHppoc2WsvrNMa7rste+jMkuvJRQhM1y az+zWgguE2ey+sZBImrC7cWD25Spf4zzIkwQwGXFfSbk5fxopUEn8I/wpV6cNPICqI3kbc k48IrDSfeaAwzpQWKzFvehqCMECrNWk= X-MC-Unique: EpW8h2KiOeujYIFYA0AugA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD and NetBSD Date: Thu, 11 Jun 2020 15:44:10 -0400 Message-Id: <20200611194449.31468-77-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Carlier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: David Carlier getpid is good enough in a mono thread context, however thr_self/_lwp_self reflects the real current thread identifier from a given process. Signed-off-by: David Carlier Signed-off-by: Paolo Bonzini Signed-off-by: David Carlier --- util/oslib-posix.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 062236a1ab..916f1be224 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -48,11 +48,13 @@ #ifdef __FreeBSD__ #include #include +#include #include #endif =20 #ifdef __NetBSD__ #include +#include #endif =20 #include "qemu/mmap-alloc.h" @@ -84,6 +86,13 @@ int qemu_get_thread_id(void) { #if defined(__linux__) return syscall(SYS_gettid); +#elif defined(__FreeBSD__) + /* thread id is up to INT_MAX */ + long tid; + thr_self(&tid); + return (int)tid; +#elif defined(__NetBSD__) + return _lwp_self(); #else return getpid(); #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907097; cv=none; d=zohomail.com; s=zohoarc; b=N5HZ7NwhDXbDAhve2HcyLSpeePlO7c0W1/it32SP5vS2r/vqak51Ly0iMNEge49fwVdqM2P6KGiR0HGoVROED1XJNnrjBIJxBLvK6Ini/8KLtU8TEelovxDmYCmcb9d2lqct23fxH7NoiVvB84GEgejFMR+in+StNBVm/zMptS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907097; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y83Uw1+pZMxcGDtGlla7jbfWJHY6UGPWVFOHylfE1Lo=; b=h3fJFpu64zZqXuDPM16/VzPVcz/tFUQekX8d40/QuGjQS9bsi74tRwgLwUPM6GHg7ucU46SPrPduyH4xl6Vy/35HET+zF21ptlNrFqS6XthoS+jPoQqFPrswwU8zmBSR3vZ4d80VamrFklxQ9m26v4CUJzONAtUBPp2wn7aLX44= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907097145797.0050227823742; Thu, 11 Jun 2020 13:24:57 -0700 (PDT) Received: from localhost ([::1]:37958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTkr-0004Rt-Lf for importer@patchew.org; Thu, 11 Jun 2020 16:24:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAB-0001Sw-Pq for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:59 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:35783 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA8-0001MF-0h for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-vxxmsrYCPCeHCnbACknC0Q-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23C0D107ACCD for ; Thu, 11 Jun 2020 19:46:49 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEBA660CC0; Thu, 11 Jun 2020 19:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904815; 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=Y83Uw1+pZMxcGDtGlla7jbfWJHY6UGPWVFOHylfE1Lo=; b=LUpR4zB5sWSjla6IonJsXykkaT9DmEV1/cfx/BRN38f7uJMXtYGLJL7I4iIlApkEPU/i0X o7BYslZcZl2Lf2Y/TDA0KC4H99qF279/w2M55SE1tfTm3Q9a8PYLX9nJDQYZSyENGGQt/D sgLQUK4JxT5iQr+Yei+M4Yl7X2ha0CI= X-MC-Unique: vxxmsrYCPCeHCnbACknC0Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 077/115] memory: Make 'info mtree' not display disabled regions by default Date: Thu, 11 Jun 2020 15:44:11 -0400 Message-Id: <20200611194449.31468-78-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 We might have many disabled memory regions, making the 'info mtree' output too verbose to be useful. Remove the disabled regions in the default output, but allow the monitor user to display them using the '-D' option. Before: (qemu) info mtree memory-region: system 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-0000000007ffffff (prio 0, ram): alias ram-below-4g @= pc.ram 0000000000000000-0000000007ffffff 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc= .bios 0000000000020000-000000000003ffff 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios 00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region @= pci 00000000000a0000-00000000000bffff 00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000c0000-00000000000c3fff [disabled] 00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000c0000-00000000000c3fff [disabled] 00000000000c0000-00000000000c3fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000c0000-00000000000c3fff [disabled] 00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c0000-00000000000c3fff 00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000c4000-00000000000c7fff [disabled] 00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000c4000-00000000000c7fff [disabled] 00000000000c4000-00000000000c7fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000c4000-00000000000c7fff [disabled] 00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c4000-00000000000c7fff 00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000c8000-00000000000cbfff [disabled] 00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000c8000-00000000000cbfff [disabled] 00000000000c8000-00000000000cbfff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000c8000-00000000000cbfff [disabled] 00000000000c8000-00000000000cbfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c8000-00000000000cbfff 00000000000cc000-00000000000cffff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000cc000-00000000000cffff [disabled] 00000000000cc000-00000000000cffff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000cc000-00000000000cffff [disabled] 00000000000cc000-00000000000cffff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000cc000-00000000000cffff [disabled] 00000000000cc000-00000000000cffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000cc000-00000000000cffff 00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000d0000-00000000000d3fff [disabled] 00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000d0000-00000000000d3fff [disabled] 00000000000d0000-00000000000d3fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000d0000-00000000000d3fff [disabled] 00000000000d0000-00000000000d3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d0000-00000000000d3fff 00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000d4000-00000000000d7fff [disabled] 00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000d4000-00000000000d7fff [disabled] 00000000000d4000-00000000000d7fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000d4000-00000000000d7fff [disabled] 00000000000d4000-00000000000d7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d4000-00000000000d7fff 00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000d8000-00000000000dbfff [disabled] 00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000d8000-00000000000dbfff [disabled] 00000000000d8000-00000000000dbfff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000d8000-00000000000dbfff [disabled] 00000000000d8000-00000000000dbfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d8000-00000000000dbfff 00000000000dc000-00000000000dffff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000dc000-00000000000dffff [disabled] 00000000000dc000-00000000000dffff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000dc000-00000000000dffff [disabled] 00000000000dc000-00000000000dffff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000dc000-00000000000dffff [disabled] 00000000000dc000-00000000000dffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000dc000-00000000000dffff 00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000e0000-00000000000e3fff [disabled] 00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000e0000-00000000000e3fff [disabled] 00000000000e0000-00000000000e3fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000e0000-00000000000e3fff [disabled] 00000000000e0000-00000000000e3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e0000-00000000000e3fff 00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000e4000-00000000000e7fff [disabled] 00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000e4000-00000000000e7fff [disabled] 00000000000e4000-00000000000e7fff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000e4000-00000000000e7fff [disabled] 00000000000e4000-00000000000e7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e4000-00000000000e7fff 00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000e8000-00000000000ebfff [disabled] 00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000e8000-00000000000ebfff [disabled] 00000000000e8000-00000000000ebfff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000e8000-00000000000ebfff [disabled] 00000000000e8000-00000000000ebfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e8000-00000000000ebfff 00000000000ec000-00000000000effff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000ec000-00000000000effff [disabled] 00000000000ec000-00000000000effff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000ec000-00000000000effff [disabled] 00000000000ec000-00000000000effff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000ec000-00000000000effff [disabled] 00000000000ec000-00000000000effff (prio 1, i/o): alias pam-pci @pci 0= 0000000000ec000-00000000000effff 00000000000f0000-00000000000fffff (prio 1, ram): alias pam-ram @pc.ra= m 00000000000f0000-00000000000fffff [disabled] 00000000000f0000-00000000000fffff (prio 1, ram): alias pam-pci @pc.ra= m 00000000000f0000-00000000000fffff [disabled] 00000000000f0000-00000000000fffff (prio 1, ram): alias pam-rom @pc.ra= m 00000000000f0000-00000000000fffff [disabled] 00000000000f0000-00000000000fffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000f0000-00000000000fffff 00000000fec00000-00000000fec00fff (prio 0, i/o): ioapic 00000000fed00000-00000000fed003ff (prio 0, i/o): hpet 00000000fee00000-00000000feefffff (prio 4096, i/o): apic-msi After: (qemu) info mtree memory-region: system 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-0000000007ffffff (prio 0, ram): alias ram-below-4g @= pc.ram 0000000000000000-0000000007ffffff 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc= .bios 0000000000020000-000000000003ffff 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios 00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region @= pci 00000000000a0000-00000000000bffff 00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c0000-00000000000c3fff 00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c4000-00000000000c7fff 00000000000c8000-00000000000cbfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000c8000-00000000000cbfff 00000000000cc000-00000000000cffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000cc000-00000000000cffff 00000000000d0000-00000000000d3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d0000-00000000000d3fff 00000000000d4000-00000000000d7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d4000-00000000000d7fff 00000000000d8000-00000000000dbfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000d8000-00000000000dbfff 00000000000dc000-00000000000dffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000dc000-00000000000dffff 00000000000e0000-00000000000e3fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e0000-00000000000e3fff 00000000000e4000-00000000000e7fff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e4000-00000000000e7fff 00000000000e8000-00000000000ebfff (prio 1, i/o): alias pam-pci @pci 0= 0000000000e8000-00000000000ebfff 00000000000ec000-00000000000effff (prio 1, i/o): alias pam-pci @pci 0= 0000000000ec000-00000000000effff 00000000000f0000-00000000000fffff (prio 1, i/o): alias pam-pci @pci 0= 0000000000f0000-00000000000fffff 00000000fec00000-00000000fec00fff (prio 0, i/o): ioapic 00000000fed00000-00000000fed003ff (prio 0, i/o): hpet 00000000fee00000-00000000feefffff (prio 4096, i/o): apic-msi The old behavior is preserved using 'info mtree -D'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 7 ++-- include/exec/memory.h | 2 +- memory.c | 75 +++++++++++++++++++++++-------------------- monitor/misc.c | 3 +- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ca5198438d..30209e3903 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -254,11 +254,12 @@ ERST =20 { .name =3D "mtree", - .args_type =3D "flatview:-f,dispatch_tree:-d,owner:-o", - .params =3D "[-f][-d][-o]", + .args_type =3D "flatview:-f,dispatch_tree:-d,owner:-o,disabled:-D= ", + .params =3D "[-f][-d][-o][-D]", .help =3D "show memory tree (-f: dump flat view for address = spaces;" "-d: dump dispatch tree, valid with -f only);" - "-o: dump region owners/parents", + "-o: dump region owners/parents;" + "-D: dump disabled regions", .cmd =3D hmp_info_mtree, }, =20 diff --git a/include/exec/memory.h b/include/exec/memory.h index 48df5abe13..bd7fdd6081 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1984,7 +1984,7 @@ void memory_global_dirty_log_start(void); */ void memory_global_dirty_log_stop(void); =20 -void mtree_info(bool flatview, bool dispatch_tree, bool owner); +void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabl= ed); =20 /** * memory_region_dispatch_read: perform a read directly to the specified diff --git a/memory.c b/memory.c index 91ceaf9fcf..2f15a4b250 100644 --- a/memory.c +++ b/memory.c @@ -2882,7 +2882,7 @@ static void mtree_print_mr_owner(const MemoryRegion *= mr) static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, hwaddr base, MemoryRegionListHead *alias_print_queue, - bool owner) + bool owner, bool display_disabled) { MemoryRegionList *new_ml, *ml, *next_ml; MemoryRegionListHead submr_print_queue; @@ -2894,10 +2894,6 @@ static void mtree_print_mr(const MemoryRegion *mr, u= nsigned int level, return; } =20 - for (i =3D 0; i < level; i++) { - qemu_printf(MTREE_INDENT); - } - cur_start =3D base + mr->addr; cur_end =3D cur_start + MR_SIZE(mr->size); =20 @@ -2926,35 +2922,46 @@ static void mtree_print_mr(const MemoryRegion *mr, = unsigned int level, ml->mr =3D mr->alias; QTAILQ_INSERT_TAIL(alias_print_queue, ml, mrqueue); } - qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx - " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx - "-" TARGET_FMT_plx "%s", - cur_start, cur_end, - mr->priority, - mr->nonvolatile ? "nv-" : "", - memory_region_type((MemoryRegion *)mr), - memory_region_name(mr), - memory_region_name(mr->alias), - mr->alias_offset, - mr->alias_offset + MR_SIZE(mr->size), - mr->enabled ? "" : " [disabled]"); - if (owner) { - mtree_print_mr_owner(mr); + if (mr->enabled || display_disabled) { + for (i =3D 0; i < level; i++) { + qemu_printf(MTREE_INDENT); + } + qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx + "-" TARGET_FMT_plx "%s", + cur_start, cur_end, + mr->priority, + mr->nonvolatile ? "nv-" : "", + memory_region_type((MemoryRegion *)mr), + memory_region_name(mr), + memory_region_name(mr->alias), + mr->alias_offset, + mr->alias_offset + MR_SIZE(mr->size), + mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mr); + } + qemu_printf("\n"); } } else { - qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx - " (prio %d, %s%s): %s%s", - cur_start, cur_end, - mr->priority, - mr->nonvolatile ? "nv-" : "", - memory_region_type((MemoryRegion *)mr), - memory_region_name(mr), - mr->enabled ? "" : " [disabled]"); - if (owner) { - mtree_print_mr_owner(mr); + if (mr->enabled || display_disabled) { + for (i =3D 0; i < level; i++) { + qemu_printf(MTREE_INDENT); + } + qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): %s%s", + cur_start, cur_end, + mr->priority, + mr->nonvolatile ? "nv-" : "", + memory_region_type((MemoryRegion *)mr), + memory_region_name(mr), + mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mr); + } + qemu_printf("\n"); } } - qemu_printf("\n"); =20 QTAILQ_INIT(&submr_print_queue); =20 @@ -2977,7 +2984,7 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { mtree_print_mr(ml->mr, level + 1, cur_start, - alias_print_queue, owner); + alias_print_queue, owner, display_disabled); } =20 QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, mrqueue, next_ml) { @@ -3088,7 +3095,7 @@ static gboolean mtree_info_flatview_free(gpointer key= , gpointer value, return true; } =20 -void mtree_info(bool flatview, bool dispatch_tree, bool owner) +void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabl= ed) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; @@ -3136,14 +3143,14 @@ void mtree_info(bool flatview, bool dispatch_tree, = bool owner) =20 QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { qemu_printf("address-space: %s\n", as->name); - mtree_print_mr(as->root, 1, 0, &ml_head, owner); + mtree_print_mr(as->root, 1, 0, &ml_head, owner, disabled); qemu_printf("\n"); } =20 /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { qemu_printf("memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(ml->mr, 1, 0, &ml_head, owner); + mtree_print_mr(ml->mr, 1, 0, &ml_head, owner, disabled); qemu_printf("\n"); } =20 diff --git a/monitor/misc.c b/monitor/misc.c index f5207cd242..89bb970b00 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -957,8 +957,9 @@ static void hmp_info_mtree(Monitor *mon, const QDict *q= dict) bool flatview =3D qdict_get_try_bool(qdict, "flatview", false); bool dispatch_tree =3D qdict_get_try_bool(qdict, "dispatch_tree", fals= e); bool owner =3D qdict_get_try_bool(qdict, "owner", false); + bool disabled =3D qdict_get_try_bool(qdict, "disabled", false); =20 - mtree_info(flatview, dispatch_tree, owner); + mtree_info(flatview, dispatch_tree, owner, disabled); } =20 #ifdef CONFIG_PROFILER --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907235; cv=none; d=zohomail.com; s=zohoarc; b=i5bjIFanJem8Sbb0L1TmHailKzH84yj4QvISr3UybR+Y//3+mX0SH/a/e+tDute8R9SC/eZsNvrHTaweotQX4TxIX6Lg550dTBAyqProa81PozE4levnuc4KpXigfTfhTsswT0hOV25UfUWPgeg0e+9DhNRcsANsl9O+SiDmexM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907235; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dvnqahXf1d5rfZTpxY9l3gz0FJxljM6WL4LK/RhTZRI=; b=kB/bQoXmXrOmnLzTaP2JrxFzrD8F+3znnxJqn4RTHIunXft6gPXEjy1B0dJPa/LfUcd4jjg5I+MxrVkFThy4JkzUQDz2mqb84jaU5dxZVI0VnRvI15KxJRfyZNDrr3xuwCqnWs3bAzBKh9AmN+lzz4XRaS/GSS+LQYiqVpIRjVg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907235619500.9726877285259; Thu, 11 Jun 2020 13:27:15 -0700 (PDT) Received: from localhost ([::1]:46620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTn8-000059-Bs for importer@patchew.org; Thu, 11 Jun 2020 16:27:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAD-0001VQ-4V for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44108 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAB-0001N5-8u for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-sXNSvTfgMBWdiur8bDxi7Q-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A492C8B8C64 for ; Thu, 11 Jun 2020 19:46:49 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AD0460CC0; Thu, 11 Jun 2020 19:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904818; 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=dvnqahXf1d5rfZTpxY9l3gz0FJxljM6WL4LK/RhTZRI=; b=N51qkyWAAeCe6+shJ95tQKPgs6e1BlJx7iN7D5GnUzpMmenjIN8uYaKXC0IsakWvMYLIQF iDsmubGd8z1TyjJcuNY3MnYBhpd4C6HwWlS0c17d1zzuA/lxZ/0ac3xJQwV9vD58AlA4m2 DH+ks8tKjM8CBAYeTBVKW6Ctxwh2tLY= X-MC-Unique: sXNSvTfgMBWdiur8bDxi7Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 078/115] qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute Date: Thu, 11 Jun 2020 15:44:12 -0400 Message-Id: <20200611194449.31468-79-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 After upgrading to Ubuntu 20.04 LTS, GCC 9.3 complains: util/qemu-thread-posix.c: In function =E2=80=98qemu_thread_exit=E2=80=99: util/qemu-thread-posix.c:577:6: error: function might be candidate for at= tribute =E2=80=98noreturn=E2=80=99 [-Werror=3Dsuggest-attribute=3Dnoreturn] 577 | void qemu_thread_exit(void *retval) | ^~~~~~~~~~~~~~~~ Fix by marking the qemu_thread_exit function with QEMU_NORETURN to set the 'noreturn' attribute. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- include/qemu/thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index d22848138e..06c058fb58 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -177,7 +177,7 @@ void qemu_thread_create(QemuThread *thread, const char = *name, void *qemu_thread_join(QemuThread *thread); void qemu_thread_get_self(QemuThread *thread); bool qemu_thread_is_self(QemuThread *thread); -void qemu_thread_exit(void *retval); +void qemu_thread_exit(void *retval) QEMU_NORETURN; void qemu_thread_naming(bool enable); =20 struct Notifier; --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591906799; cv=none; d=zohomail.com; s=zohoarc; b=YOP49P2G/+963W1jYe9Y+6/DjRe9ZFqDtOEqYjfNYAeLADExLjvM8cljtLypcoTnKuA4G8dVn1x2UTECW7ktJ91Rfk0ZEdHr1/v1MMRTrWmI3rapb2rV8axCyjax8dga9IEwl9oLEgLicBsj0wGkSBraX/9dh6v9cwGt9/S7wk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591906799; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mg9ONK0InEVWqpvTKJWUqO2Fsf0hqgK0J0g+zDJ5GR8=; b=c/k1n9uMjq38Vzzcvy9x3YNPrtMn4Cdb1oPc54MysQKDJ12K6t7MAwdGmPAzPEjlEvVTIFFeAbCUbb3rfnooqTVsRZClOvdrftRxOedbNjCA86KuMMTsC3a/WEJxRg4I8dhdeJb3rsFy2Q0jfhDmT1V92A/cOLJchgi3Rfwr3dw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591906799718310.23607959108347; Thu, 11 Jun 2020 13:19:59 -0700 (PDT) Received: from localhost ([::1]:49334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTg6-0004PH-Eq for importer@patchew.org; Thu, 11 Jun 2020 16:19:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTA9-0001PU-J9 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47704 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA7-0001M2-Ey for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-RY5uj7VXOTuyZSA-2doIeg-1; Thu, 11 Jun 2020 15:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF1583DE6B; Thu, 11 Jun 2020 19:46:50 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB16860CD3; Thu, 11 Jun 2020 19:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904814; 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=Mg9ONK0InEVWqpvTKJWUqO2Fsf0hqgK0J0g+zDJ5GR8=; b=QgKEDzGhsC6eYEjVrQSRbcrUbgNUCq0Sd7kcnbSV1okIgRtCGKO2QmHirZdFMqP6fOQb5q b6a1JAQayLBjie3CmNf37FWPqUO24Z++iGoDKz0wu5iH1nRQAOY0pWg3o1v2Dd091gceDB khEe/GQ6snCqe1yCRTPWs4W7m8W9adE= X-MC-Unique: RY5uj7VXOTuyZSA-2doIeg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 079/115] configure: Do not ignore malloc value Date: Thu, 11 Jun 2020 15:44:13 -0400 Message-Id: <20200611194449.31468-80-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leonid Bloch , Leonid Bloch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Leonid Bloch Not checking the value of malloc will cause a warning with GCC 10.1, which may result in configuration failure, with the following line in config.log: config-temp/qemu-conf.c:2:18: error: ignoring return value of =C3=A2=E2=82= =AC=CB=9Cmalloc=C3=A2=E2=82=AC=E2=84=A2 declared with attribute =C3=A2=E2= =82=AC=CB=9Cwarn_unused_result=C3=A2=E2=82=AC=E2=84=A2 [-Werror=3Dunused-re= sult] 2 | int main(void) { malloc(1); return 0; } | ^~~~~~~~~ Signed-off-by: Leonid Bloch Message-Id: <20200524221204.9791-1-lb.workbox@gmail.com> Signed-off-by: Paolo Bonzini --- configure | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 53a6dd0297..dbc16b5656 100755 --- a/configure +++ b/configure @@ -4587,7 +4587,13 @@ fi if test "$tcmalloc" =3D "yes" ; then cat > $TMPC << EOF #include -int main(void) { malloc(1); return 0; } +int main(void) { + void *tmp =3D malloc(1); + if (tmp !=3D NULL) { + return 0; + } + return 1; +} EOF =20 if compile_prog "" "-ltcmalloc" ; then @@ -4603,7 +4609,13 @@ fi if test "$jemalloc" =3D "yes" ; then cat > $TMPC << EOF #include -int main(void) { malloc(1); return 0; } +int main(void) { + void *tmp =3D malloc(1); + if (tmp !=3D NULL) { + return 0; + } + return 1; +} EOF =20 if compile_prog "" "-ljemalloc" ; then @@ -6164,7 +6176,9 @@ if test "$sanitizers" =3D "yes" ; then #include int main(void) { void *tmp =3D malloc(10); - return *(int *)(tmp + 2); + if (tmp !=3D NULL) { + return *(int *)(tmp + 2); + } } EOF if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Dundefined" ""; then --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908420; cv=none; d=zohomail.com; s=zohoarc; b=Gv8ZfkyOekV1RomD8x4TrpFoHu8ISe6CX655C7dxN4a6gF2MExIOGuy6VV0wjPtI5Z0f5nlDP3wG41b7rHbJKPbl7u8G4duTjCvmzAgdDtccWqeijUOiUxT6hBj2rl8ycKBeEslOeuTW0uxuFDC01z8rIaWa4m0/yKyTvhU9GgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908420; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DdY3ERWTiaZOd3Bn0BxtqRsKwTUqDQ8SFHOZ6ljXqek=; b=OPFxLn2ySpID6X6FRt0uC7tEijTwKjVN9vjZCjBDDjxuN/VnFACOBLwe5IY1oywOG45w8nCusUrbvXheWEoAz5j0SpBmMwivDIxGi3aywEmLhpxywhXkqt/lsMs2vok9sr3EmpNkID0B7Pi+cCKHZveJmj9V4DIuKzDKWfbEHGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908420368686.5132845409623; Thu, 11 Jun 2020 13:47:00 -0700 (PDT) Received: from localhost ([::1]:55392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU6F-0007jc-7z for importer@patchew.org; Thu, 11 Jun 2020 16:46:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAL-0001md-Ln for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:09 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36178 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAI-0001PF-NE for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-420-q4dJ48Q4NRykTeqRCBR8Rw-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AB708B8C61; Thu, 11 Jun 2020 19:46:51 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C740E60CC0; Thu, 11 Jun 2020 19:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904825; 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=DdY3ERWTiaZOd3Bn0BxtqRsKwTUqDQ8SFHOZ6ljXqek=; b=KghfFvdOfa7FxJejRrVbm/gfSqy8g9eytkOgQDw/IIib2xzCko+0m8g9dTh2sNjQPxJWkm Rb+XQRU6oQmJr0JSF1lo0e/+3ObiZIMzh429Z5G2XpCw9HF/P7Y2hK8CWs6mdhwzr0AgVy Ii7WMY5u0i+g6QdE5c0P2l2fYFJzzb4= X-MC-Unique: q4dJ48Q4NRykTeqRCBR8Rw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 080/115] exec: set map length to zero when returning NULL Date: Thu, 11 Jun 2020 15:44:14 -0400 Message-Id: <20200611194449.31468-81-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Prasad J Pandit , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Prasad J Pandit When mapping physical memory into host's virtual address space, 'address_space_map' may return NULL if BounceBuffer is in_use. Set and return '*plen =3D 0' to avoid later NULL pointer dereference. Reported-by: Alexander Bulekov Fixes: https://bugs.launchpad.net/qemu/+bug/1878259 Suggested-by: Paolo Bonzini Suggested-by: Peter Maydell Signed-off-by: Prasad J Pandit Message-Id: <20200526111743.428367-1-ppandit@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- exec.c | 1 + include/exec/memory.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 9cbde85d8c..778263f1c6 100644 --- a/exec.c +++ b/exec.c @@ -3540,6 +3540,7 @@ void *address_space_map(AddressSpace *as, =20 if (!memory_access_is_direct(mr, is_write)) { if (atomic_xchg(&bounce.in_use, true)) { + *plen =3D 0; return NULL; } /* Avoid unbounded allocations */ diff --git a/include/exec/memory.h b/include/exec/memory.h index bd7fdd6081..af8ca7824e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2314,7 +2314,8 @@ bool address_space_access_valid(AddressSpace *as, hwa= ddr addr, hwaddr len, /* address_space_map: map a physical memory region into a host virtual add= ress * * May map a subset of the requested range, given by and returned in @plen. - * May return %NULL if resources needed to perform the mapping are exhaust= ed. + * May return %NULL and set *@plen to zero(0), if resources needed to perf= orm + * the mapping are exhausted. * Use only for reads OR writes - not for read-modify-write operations. * Use cpu_register_map_client() to know when retrying the map operation is * likely to succeed. --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908413; cv=none; d=zohomail.com; s=zohoarc; b=cFgJ6hdplIdri+WZUbroubz/Jz6u4Jw5QcKjCujzeE49fuiV+nCPwUKDscGZQgPdK7g0tfeUOruqUbdHJZGR2Ue8rU6tDPtYI4T4VKH/UzXFp7GPe9leJ4VSWif21x+iKfl3z8CFyCY2DBpUQKzInM6QBMjTY+Mn8ydjhVPBpzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908413; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ttWdGOzpdcJg4wEA+HuhLXuMYEJqrt82pCBDVAzZz10=; b=F132DKe9QV7ah3ZQD1Pv3c++cMp9G/HQqJr+mGSaGhX/DF23YfbRm5wRLMIZKdLdGYxWc5E/q+dWHmiQtq1ZAB9SEGDKxsqPq/biHOKDULWbl+1dEldetC94IpwsJTbn8ZRhU19CX3HEISe6PTHYKuif5SN+dcodFPF13gsOGLc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919084132281003.6152894151612; Thu, 11 Jun 2020 13:46:53 -0700 (PDT) Received: from localhost ([::1]:54742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU67-0007T3-TC for importer@patchew.org; Thu, 11 Jun 2020 16:46:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAD-0001WP-IY for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43974 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA9-0001MZ-3E for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-WNkV67p-MxiQSe8gYda_WA-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEC71107B001; Thu, 11 Jun 2020 19:46:51 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 685D260CC0; Thu, 11 Jun 2020 19:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904816; 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=ttWdGOzpdcJg4wEA+HuhLXuMYEJqrt82pCBDVAzZz10=; b=SP2/oJD7/0pWIWQVpb7au9U+eD6elTMbdOdyqUHx2tQwK30OcbVeKn1JmeA2su3mV38Gs0 jntkRwnOH27pcqfk7DWJjbEurTGj9B1IRnkVNIdQSkD2M3eN5QtYla/l3hc+oWwYI60t8z XnColPi7XHl58bbWBlLfoPlws2cAh4E= X-MC-Unique: WNkV67p-MxiQSe8gYda_WA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 081/115] target/i386: fix IEEE x87 floating-point exception raising Date: Thu, 11 Jun 2020 15:44:15 -0400 Message-Id: <20200611194449.31468-82-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers Most x87 instruction implementations fail to raise the expected IEEE floating-point exceptions because they do nothing to convert the exception state from the softfloat machinery into the exception flags in the x87 status word. There is special-case handling of division to raise the divide-by-zero exception, but that handling is itself buggy: it raises the exception in inappropriate cases (inf / 0 and nan / 0, which should not raise any exceptions, and 0 / 0, which should raise "invalid" instead). Fix this by converting the floating-point exceptions raised during an operation by the softfloat machinery into exceptions in the x87 status word (passing through the existing fpu_set_exception function for handling related to trapping exceptions). There are special cases where some functions convert to integer internally but exceptions from that conversion are not always correct exceptions for the instruction to raise. There might be scope for some simplification if the softfloat exception state either could always be assumed to be in sync with the state in the status word, or could always be ignored at the start of each instruction and just set to 0 then; I haven't looked into that in detail, and it might run into interactions with the various ways the emulation does not yet handle trapping exceptions properly. I think the approach taken here, of saving the softfloat state, setting exceptions there to 0 and then merging the old exceptions back in after carrying out the operation, is conservatively safe. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/fpu_helper.c | 126 +++- tests/tcg/i386/test-i386-fp-exceptions.c | 831 +++++++++++++++++++++++ 2 files changed, 926 insertions(+), 31 deletions(-) create mode 100644 tests/tcg/i386/test-i386-fp-exceptions.c diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c index 9c93f385b1..8ef5b463ea 100644 --- a/target/i386/fpu_helper.c +++ b/target/i386/fpu_helper.c @@ -161,12 +161,32 @@ static void fpu_set_exception(CPUX86State *env, int m= ask) } } =20 +static inline uint8_t save_exception_flags(CPUX86State *env) +{ + uint8_t old_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + return old_flags; +} + +static void merge_exception_flags(CPUX86State *env, uint8_t old_flags) +{ + uint8_t new_flags =3D get_float_exception_flags(&env->fp_status); + float_raise(old_flags, &env->fp_status); + fpu_set_exception(env, + ((new_flags & float_flag_invalid ? FPUS_IE : 0) | + (new_flags & float_flag_divbyzero ? FPUS_ZE : 0) | + (new_flags & float_flag_overflow ? FPUS_OE : 0) | + (new_flags & float_flag_underflow ? FPUS_UE : 0) | + (new_flags & float_flag_inexact ? FPUS_PE : 0) | + (new_flags & float_flag_input_denormal ? FPUS_DE : = 0))); +} + static inline floatx80 helper_fdiv(CPUX86State *env, floatx80 a, floatx80 = b) { - if (floatx80_is_zero(b)) { - fpu_set_exception(env, FPUS_ZE); - } - return floatx80_div(a, b, &env->fp_status); + uint8_t old_flags =3D save_exception_flags(env); + floatx80 ret =3D floatx80_div(a, b, &env->fp_status); + merge_exception_flags(env, old_flags); + return ret; } =20 static void fpu_raise_exception(CPUX86State *env, uintptr_t retaddr) @@ -183,6 +203,7 @@ static void fpu_raise_exception(CPUX86State *env, uintp= tr_t retaddr) =20 void helper_flds_FT0(CPUX86State *env, uint32_t val) { + uint8_t old_flags =3D save_exception_flags(env); union { float32 f; uint32_t i; @@ -190,10 +211,12 @@ void helper_flds_FT0(CPUX86State *env, uint32_t val) =20 u.i =3D val; FT0 =3D float32_to_floatx80(u.f, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fldl_FT0(CPUX86State *env, uint64_t val) { + uint8_t old_flags =3D save_exception_flags(env); union { float64 f; uint64_t i; @@ -201,6 +224,7 @@ void helper_fldl_FT0(CPUX86State *env, uint64_t val) =20 u.i =3D val; FT0 =3D float64_to_floatx80(u.f, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fildl_FT0(CPUX86State *env, int32_t val) @@ -210,6 +234,7 @@ void helper_fildl_FT0(CPUX86State *env, int32_t val) =20 void helper_flds_ST0(CPUX86State *env, uint32_t val) { + uint8_t old_flags =3D save_exception_flags(env); int new_fpstt; union { float32 f; @@ -221,10 +246,12 @@ void helper_flds_ST0(CPUX86State *env, uint32_t val) env->fpregs[new_fpstt].d =3D float32_to_floatx80(u.f, &env->fp_status); env->fpstt =3D new_fpstt; env->fptags[new_fpstt] =3D 0; /* validate stack entry */ + merge_exception_flags(env, old_flags); } =20 void helper_fldl_ST0(CPUX86State *env, uint64_t val) { + uint8_t old_flags =3D save_exception_flags(env); int new_fpstt; union { float64 f; @@ -236,6 +263,7 @@ void helper_fldl_ST0(CPUX86State *env, uint64_t val) env->fpregs[new_fpstt].d =3D float64_to_floatx80(u.f, &env->fp_status); env->fpstt =3D new_fpstt; env->fptags[new_fpstt] =3D 0; /* validate stack entry */ + merge_exception_flags(env, old_flags); } =20 void helper_fildl_ST0(CPUX86State *env, int32_t val) @@ -260,113 +288,107 @@ void helper_fildll_ST0(CPUX86State *env, int64_t va= l) =20 uint32_t helper_fsts_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); union { float32 f; uint32_t i; } u; =20 u.f =3D floatx80_to_float32(ST0, &env->fp_status); + merge_exception_flags(env, old_flags); return u.i; } =20 uint64_t helper_fstl_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); union { float64 f; uint64_t i; } u; =20 u.f =3D floatx80_to_float64(ST0, &env->fp_status); + merge_exception_flags(env, old_flags); return u.i; } =20 int32_t helper_fist_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int32_t val; =20 val =3D floatx80_to_int32(ST0, &env->fp_status); if (val !=3D (int16_t)val) { + set_float_exception_flags(float_flag_invalid, &env->fp_status); val =3D -32768; } + merge_exception_flags(env, old_flags); return val; } =20 int32_t helper_fistl_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int32_t val; - signed char old_exp_flags; - - old_exp_flags =3D get_float_exception_flags(&env->fp_status); - set_float_exception_flags(0, &env->fp_status); =20 val =3D floatx80_to_int32(ST0, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { val =3D 0x80000000; } - set_float_exception_flags(get_float_exception_flags(&env->fp_status) - | old_exp_flags, &env->fp_status); + merge_exception_flags(env, old_flags); return val; } =20 int64_t helper_fistll_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int64_t val; - signed char old_exp_flags; - - old_exp_flags =3D get_float_exception_flags(&env->fp_status); - set_float_exception_flags(0, &env->fp_status); =20 val =3D floatx80_to_int64(ST0, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { val =3D 0x8000000000000000ULL; } - set_float_exception_flags(get_float_exception_flags(&env->fp_status) - | old_exp_flags, &env->fp_status); + merge_exception_flags(env, old_flags); return val; } =20 int32_t helper_fistt_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int32_t val; =20 val =3D floatx80_to_int32_round_to_zero(ST0, &env->fp_status); if (val !=3D (int16_t)val) { + set_float_exception_flags(float_flag_invalid, &env->fp_status); val =3D -32768; } + merge_exception_flags(env, old_flags); return val; } =20 int32_t helper_fisttl_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int32_t val; - signed char old_exp_flags; - - old_exp_flags =3D get_float_exception_flags(&env->fp_status); - set_float_exception_flags(0, &env->fp_status); =20 val =3D floatx80_to_int32_round_to_zero(ST0, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { val =3D 0x80000000; } - set_float_exception_flags(get_float_exception_flags(&env->fp_status) - | old_exp_flags, &env->fp_status); + merge_exception_flags(env, old_flags); return val; } =20 int64_t helper_fisttll_ST0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int64_t val; - signed char old_exp_flags; - - old_exp_flags =3D get_float_exception_flags(&env->fp_status); - set_float_exception_flags(0, &env->fp_status); =20 val =3D floatx80_to_int64_round_to_zero(ST0, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { val =3D 0x8000000000000000ULL; } - set_float_exception_flags(get_float_exception_flags(&env->fp_status) - | old_exp_flags, &env->fp_status); + merge_exception_flags(env, old_flags); return val; } =20 @@ -449,24 +471,29 @@ static const int fcom_ccval[4] =3D {0x0100, 0x4000, 0= x0000, 0x4500}; =20 void helper_fcom_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); FloatRelation ret; =20 ret =3D floatx80_compare(ST0, FT0, &env->fp_status); env->fpus =3D (env->fpus & ~0x4500) | fcom_ccval[ret + 1]; + merge_exception_flags(env, old_flags); } =20 void helper_fucom_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); FloatRelation ret; =20 ret =3D floatx80_compare_quiet(ST0, FT0, &env->fp_status); env->fpus =3D (env->fpus & ~0x4500) | fcom_ccval[ret + 1]; + merge_exception_flags(env, old_flags); } =20 static const int fcomi_ccval[4] =3D {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C}; =20 void helper_fcomi_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int eflags; FloatRelation ret; =20 @@ -474,10 +501,12 @@ void helper_fcomi_ST0_FT0(CPUX86State *env) eflags =3D cpu_cc_compute_all(env, CC_OP); eflags =3D (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1]; CC_SRC =3D eflags; + merge_exception_flags(env, old_flags); } =20 void helper_fucomi_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); int eflags; FloatRelation ret; =20 @@ -485,26 +514,35 @@ void helper_fucomi_ST0_FT0(CPUX86State *env) eflags =3D cpu_cc_compute_all(env, CC_OP); eflags =3D (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1]; CC_SRC =3D eflags; + merge_exception_flags(env, old_flags); } =20 void helper_fadd_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); ST0 =3D floatx80_add(ST0, FT0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fmul_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); ST0 =3D floatx80_mul(ST0, FT0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fsub_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); ST0 =3D floatx80_sub(ST0, FT0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fsubr_ST0_FT0(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); ST0 =3D floatx80_sub(FT0, ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fdiv_ST0_FT0(CPUX86State *env) @@ -521,22 +559,30 @@ void helper_fdivr_ST0_FT0(CPUX86State *env) =20 void helper_fadd_STN_ST0(CPUX86State *env, int st_index) { + uint8_t old_flags =3D save_exception_flags(env); ST(st_index) =3D floatx80_add(ST(st_index), ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fmul_STN_ST0(CPUX86State *env, int st_index) { + uint8_t old_flags =3D save_exception_flags(env); ST(st_index) =3D floatx80_mul(ST(st_index), ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fsub_STN_ST0(CPUX86State *env, int st_index) { + uint8_t old_flags =3D save_exception_flags(env); ST(st_index) =3D floatx80_sub(ST(st_index), ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fsubr_STN_ST0(CPUX86State *env, int st_index) { + uint8_t old_flags =3D save_exception_flags(env); ST(st_index) =3D floatx80_sub(ST0, ST(st_index), &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fdiv_STN_ST0(CPUX86State *env, int st_index) @@ -747,6 +793,7 @@ void helper_fbld_ST0(CPUX86State *env, target_ulong ptr) =20 void helper_fbst_ST0(CPUX86State *env, target_ulong ptr) { + uint8_t old_flags =3D save_exception_flags(env); int v; target_ulong mem_ref, mem_end; int64_t val; @@ -757,13 +804,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong p= tr) val =3D floatx80_to_int64(ST0, &env->fp_status); mem_ref =3D ptr; if (val >=3D 1000000000000000000LL || val <=3D -1000000000000000000LL)= { - float_raise(float_flag_invalid, &env->fp_status); + set_float_exception_flags(float_flag_invalid, &env->fp_status); while (mem_ref < ptr + 7) { cpu_stb_data_ra(env, mem_ref++, 0, GETPC()); } cpu_stb_data_ra(env, mem_ref++, 0xc0, GETPC()); cpu_stb_data_ra(env, mem_ref++, 0xff, GETPC()); cpu_stb_data_ra(env, mem_ref++, 0xff, GETPC()); + merge_exception_flags(env, old_flags); return; } mem_end =3D mem_ref + 9; @@ -785,6 +833,7 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr) while (mem_ref < mem_end) { cpu_stb_data_ra(env, mem_ref++, 0, GETPC()); } + merge_exception_flags(env, old_flags); } =20 void helper_f2xm1(CPUX86State *env) @@ -838,6 +887,7 @@ void helper_fpatan(CPUX86State *env) =20 void helper_fxtract(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); CPU_LDoubleU temp; =20 temp.d =3D ST0; @@ -881,6 +931,7 @@ void helper_fxtract(CPUX86State *env) BIASEXPONENT(temp); ST0 =3D temp.d; } + merge_exception_flags(env, old_flags); } =20 void helper_fprem1(CPUX86State *env) @@ -1020,11 +1071,13 @@ void helper_fyl2xp1(CPUX86State *env) =20 void helper_fsqrt(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); if (floatx80_is_neg(ST0)) { env->fpus &=3D ~0x4700; /* (C3,C2,C1,C0) <-- 0000 */ env->fpus |=3D 0x400; } ST0 =3D floatx80_sqrt(ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fsincos(CPUX86State *env) @@ -1044,15 +1097,21 @@ void helper_fsincos(CPUX86State *env) =20 void helper_frndint(CPUX86State *env) { + uint8_t old_flags =3D save_exception_flags(env); ST0 =3D floatx80_round_to_int(ST0, &env->fp_status); + merge_exception_flags(env, old_flags); } =20 void helper_fscale(CPUX86State *env) { - if (floatx80_invalid_encoding(ST1)) { + uint8_t old_flags =3D save_exception_flags(env); + if (floatx80_invalid_encoding(ST1) || floatx80_invalid_encoding(ST0)) { float_raise(float_flag_invalid, &env->fp_status); ST0 =3D floatx80_default_nan(&env->fp_status); } else if (floatx80_is_any_nan(ST1)) { + if (floatx80_is_signaling_nan(ST0, &env->fp_status)) { + float_raise(float_flag_invalid, &env->fp_status); + } ST0 =3D ST1; if (floatx80_is_signaling_nan(ST0, &env->fp_status)) { float_raise(float_flag_invalid, &env->fp_status); @@ -1081,12 +1140,17 @@ void helper_fscale(CPUX86State *env) } } } else { - int n =3D floatx80_to_int32_round_to_zero(ST1, &env->fp_status); + int n; signed char save =3D env->fp_status.floatx80_rounding_precision; + uint8_t save_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + n =3D floatx80_to_int32_round_to_zero(ST1, &env->fp_status); + set_float_exception_flags(save_flags, &env->fp_status); env->fp_status.floatx80_rounding_precision =3D 80; ST0 =3D floatx80_scalbn(ST0, n, &env->fp_status); env->fp_status.floatx80_rounding_precision =3D save; } + merge_exception_flags(env, old_flags); } =20 void helper_fsin(CPUX86State *env) diff --git a/tests/tcg/i386/test-i386-fp-exceptions.c b/tests/tcg/i386/test= -i386-fp-exceptions.c new file mode 100644 index 0000000000..dfb7117c17 --- /dev/null +++ b/tests/tcg/i386/test-i386-fp-exceptions.c @@ -0,0 +1,831 @@ +/* Test floating-point exceptions. */ + +#include +#include +#include + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile float f_res; +volatile double d_res; +volatile long double ld_res; +volatile long double ld_res2; + +volatile union u ld_invalid_1 =3D { .s =3D { 1, 1234 } }; +volatile float f_snan =3D __builtin_nansf(""); +volatile double d_snan =3D __builtin_nans(""); +volatile long double ld_third =3D 1.0L / 3.0L; +volatile long double ld_snan =3D __builtin_nansl(""); +volatile long double ld_nan =3D __builtin_nanl(""); +volatile long double ld_inf =3D __builtin_infl(); +volatile long double ld_ninf =3D -__builtin_infl(); +volatile long double ld_one =3D 1.0L; +volatile long double ld_zero =3D 0.0L; +volatile long double ld_nzero =3D -0.0L; +volatile long double ld_min =3D LDBL_MIN; +volatile long double ld_max =3D LDBL_MAX; +volatile long double ld_nmax =3D -LDBL_MAX; + +#define IE (1 << 0) +#define ZE (1 << 2) +#define OE (1 << 3) +#define UE (1 << 4) +#define PE (1 << 5) +#define EXC (IE | ZE | OE | UE | PE) + +int main(void) +{ + short sw; + unsigned char out[10]; + int ret =3D 0; + int16_t res_16; + int32_t res_32; + int64_t res_64; + + __asm__ volatile ("fnclex"); + ld_res =3D f_snan; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: widen float snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D d_snan; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: widen double snan\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + f_res =3D ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (UE | PE)) { + printf("FAIL: narrow float underflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + d_res =3D ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (UE | PE)) { + printf("FAIL: narrow double underflow\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + f_res =3D ld_max; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: narrow float overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + d_res =3D ld_max; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: narrow double overflow\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + f_res =3D ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: narrow float inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + d_res =3D ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: narrow double inexact\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + f_res =3D ld_snan; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: narrow float snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + d_res =3D ld_snan; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: narrow double snan\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + f_res =3D ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: narrow float invalid\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + d_res =3D ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: narrow double invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("frndint" : "=3Dt" (ld_res) : "0" (ld_min)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: frndint min\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("frndint" : "=3Dt" (ld_res) : "0" (ld_snan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: frndint snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("frndint" : "=3Dt" (ld_res) : "0" (ld_invalid_1.ld)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: frndint invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fcom" : : "t" (ld_nan), "u" (ld_zero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fcom nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fucom" : : "t" (ld_nan), "u" (ld_zero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: fucom nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fucom" : : "t" (ld_snan), "u" (ld_zero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fucom snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fucom" : : "t" (1.0L), "u" (ld_invalid_1.ld)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fucom invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + ld_res =3D ld_max + ld_max; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: add overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_max + ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: add inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_inf + ld_ninf; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: add inf -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_snan + ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: add snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_third + ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: add invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + ld_res =3D ld_max - ld_nmax; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: sub overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_max - ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: sub inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_inf - ld_inf; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: sub inf inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_snan - ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: sub snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_third - ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: sub invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + ld_res =3D ld_max * ld_max; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: mul overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_third * ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: mul inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_min * ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (UE | PE)) { + printf("FAIL: mul underflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_inf * ld_zero; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: mul inf 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_snan * ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: mul snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_third * ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: mul invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + ld_res =3D ld_max / ld_min; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: div overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_one / ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: div inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_min / ld_max; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (UE | PE)) { + printf("FAIL: div underflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_one / ld_zero; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D ZE) { + printf("FAIL: div 1 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_inf / ld_zero; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: div inf 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_nan / ld_zero; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: div nan 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_zero / ld_zero; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: div 0 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_inf / ld_inf; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: div inf inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_snan / ld_third; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: div snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + ld_res =3D ld_third / ld_invalid_1.ld; + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: div invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_max)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fsqrt inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_nmax)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fsqrt -max\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_ninf)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fsqrt -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_snan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fsqrt snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_invalid_1.ld)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fsqrt invalid\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (ld_nzero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: fsqrt -0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fsqrt" : "=3Dt" (ld_res) : "0" (-__builtin_nanl("")= )); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: fsqrt -nan\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistp %0" : "=3Dm" (res_16) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fistp inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistp %0" : "=3Dm" (res_16) : "t" (32767.5L) : "st"= ); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistp 32767.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistp %0" : "=3Dm" (res_16) : "t" (-32768.51L) : "s= t"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistp -32768.51\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistp %0" : "=3Dm" (res_16) : "t" (ld_nan) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistp nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistp %0" : "=3Dm" (res_16) : "t" (ld_invalid_1.ld)= : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistp invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpl %0" : "=3Dm" (res_32) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fistpl inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpl %0" : "=3Dm" (res_32) : "t" (2147483647.5L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpl 2147483647.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpl %0" : "=3Dm" (res_32) : "t" (-2147483648.51L= ) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpl -2147483648.51\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpl %0" : "=3Dm" (res_32) : "t" (ld_nan) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpl nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpl %0" : "=3Dm" (res_32) : "t" (ld_invalid_1.ld= ) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpl invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpll %0" : "=3Dm" (res_64) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fistpll inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpll %0" : "=3Dm" (res_64) : "t" (0x1p63) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpll 0x1p63\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpll %0" : "=3Dm" (res_64) : "t" (-0x1.1p63L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpll -0x1.1p63\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpll %0" : "=3Dm" (res_64) : "t" (ld_nan) : "st"= ); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpll nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fistpll %0" : "=3Dm" (res_64) : "t" (ld_invalid_1.l= d) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fistpll invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fisttp inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (32768.0L) : "st= "); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp 32768\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (32768.5L) : "st= "); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp 32768.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (-32769.0L) : "s= t"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp -32769\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (-32769.5L) : "s= t"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp -32769.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (ld_nan) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttp %0" : "=3Dm" (res_16) : "t" (ld_invalid_1.ld= ) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttp invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fisttpl inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (2147483648.0L)= : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpl 2147483648\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (-2147483649.0L= ) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpl -2147483649\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (ld_nan) : "st"= ); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpl nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpl %0" : "=3Dm" (res_32) : "t" (ld_invalid_1.l= d) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpl invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (1.5L) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fisttpll inexact\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (0x1p63) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpll 0x1p63\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (-0x1.1p63L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpll -0x1.1p63\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (ld_nan) : "st= "); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpll nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fisttpll %0" : "=3Dm" (res_64) : "t" (ld_invalid_1.= ld) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fisttpll invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_zero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D ZE) { + printf("FAIL: fxtract 0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_nzero)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D ZE) { + printf("FAIL: fxtract -0\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_inf)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: fxtract inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_nan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D 0) { + printf("FAIL: fxtract nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_snan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fxtract snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fxtract" : "=3Dt" (ld_res), "=3Du" (ld_res2) : + "0" (ld_invalid_1.ld)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fxtract invalid\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_min), "u" (ld_m= ax)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (OE | PE)) { + printf("FAIL: fscale overflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_max), "u" (ld_n= max)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D (UE | PE)) { + printf("FAIL: fscale underflow\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_zero), "u" (ld_= inf)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale 0 inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_inf), "u" (ld_n= inf)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale inf -inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_one), "u" (ld_s= nan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale 1 snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : "0" (ld_snan), "u" (ld_= nan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale snan nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (ld_invalid_1.ld), "u" (ld_one)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale invalid 1\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fscale" : "=3Dt" (ld_res) : + "0" (ld_invalid_1.ld), "u" (ld_nan)); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fscale invalid nan\n"); + ret =3D 1; + } + + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (1.5L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D PE) { + printf("FAIL: fbstp 1.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (999999999999999999.= 5L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp 999999999999999999.5\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (-100000000000000000= 0.0L) : + "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp -1000000000000000000\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_inf) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp inf\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_nan) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp nan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_snan) : "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp snan\n"); + ret =3D 1; + } + __asm__ volatile ("fnclex"); + __asm__ volatile ("fbstp %0" : "=3Dm" (out) : "t" (ld_invalid_1.ld) : = "st"); + __asm__ volatile ("fnstsw" : "=3Da" (sw)); + if ((sw & EXC) !=3D IE) { + printf("FAIL: fbstp invalid\n"); + ret =3D 1; + } + + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908246; cv=none; d=zohomail.com; s=zohoarc; b=mlHB8vvZprt+VwhFXEAYcp583GJni6NSgLRuUHLnVb5HzyRJEbOpet8YVdoyHxX8vyrxJnMhbuc3rQLOcpnzlyVTFmTCfxfb0XpFYrDT9+bcb8kkuHXyh2uDgW+7EpyGhJy9FMPGy5x6mXtYbBWltlEt5miZoLZhTUszyjaKU4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908246; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S9uAilRk365iJvnPAPdOCnixuPtKLFmSsMWM9pKU9Y0=; b=EfAhR5jU0JGArnzcziGAhxO4w4ICtrNufp6eA04sEGBiVRpKO4SNXhFgwSZlW8apjL5RzGIwpE25efPajAF/GRl4dpzBpygJiPKkOTMt0VsXFqmzv7/YYlInvw1akcf9FhJMxk9Nh6gyojkM6IlFZTtINQ7NOkbm+zzcCXFRaZE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908246745400.36671196543693; Thu, 11 Jun 2020 13:44:06 -0700 (PDT) Received: from localhost ([::1]:46280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU3R-0001xY-HG for importer@patchew.org; Thu, 11 Jun 2020 16:44:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAB-0001Sg-Bi for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:59 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47043 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTA8-0001MI-3E for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:46:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-fLeL6uTDMbKLTjdkQbxhpA-1; Thu, 11 Jun 2020 15:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D48F845F2A; Thu, 11 Jun 2020 19:46:52 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC55D60CC0; Thu, 11 Jun 2020 19:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904815; 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=S9uAilRk365iJvnPAPdOCnixuPtKLFmSsMWM9pKU9Y0=; b=WAcMSglSaWdzaNJcLumNsH9kedIJnvB/unlSi7EvNTLpD5p9lj5KeYD48J5v03/EObdQql DD+P8mpR7b71VBpsXyCBOxq2YPVJ9syruAjdP/yQAWBNISKCejVqj43bK/dtTVOEHVrEIq xC4Rx7n/5tWf7pCmXb7J0rxocXBI/F4= X-MC-Unique: fLeL6uTDMbKLTjdkQbxhpA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 082/115] target/i386: correct fix for pcmpxstrx substring search Date: Thu, 11 Jun 2020 15:44:16 -0400 Message-Id: <20200611194449.31468-83-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Myers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Joseph Myers This corrects a bug introduced in my previous fix for SSE4.2 pcmpestri / pcmpestrm / pcmpistri / pcmpistrm substring search, commit ae35eea7e4a9f21dd147406dfbcd0c4c6aaf2a60. That commit fixed a bug that showed up in four GCC tests with one libc implementation. The tests in question generate random inputs to the intrinsics and compare results to a C implementation, but they only test 1024 possible random inputs, and when the tests use the cases of those instructions that work with word rather than byte inputs, it's easy to have problematic cases that show up much less frequently than that. Thus, testing with a different libc implementation, and so a different random number generator, showed up a problem with the previous patch. When investigating the previous test failures, I found the description of these instructions in the Intel manuals (starting from computing a 16x16 or 8x8 set of comparison results) confusing and hard to match up with the more optimized implementation in QEMU, and referred to AMD manuals which described the instructions in a different way. Those AMD descriptions are very explicit that the whole of the string being searched for must be found in the other operand, not running off the end of that operand; they say "If the prototype and the SUT are equal in length, the two strings must be identical for the comparison to be TRUE.". However, that statement is incorrect. In my previous commit message, I noted: The operation in this case is a search for a string (argument d to the helper) in another string (argument s to the helper); if a copy of d at a particular position would run off the end of s, the resulting output bit should be 0 whether or not the strings match in the region where they overlap, but the QEMU implementation was wrongly comparing only up to the point where s ends and counting it as a match if an initial segment of d matched a terminal segment of s. Here, "run off the end of s" means that some byte of d would overlap some byte outside of s; thus, if d has zero length, it is considered to match everywhere, including after the end of s. The description "some byte of d would overlap some byte outside of s" is accurate only when understood to refer to overlapping some byte *within the 16-byte operand* but at or after the zero terminator; it is valid to run over the end of s if the end of s is the end of the 16-byte operand. So the fix in the previous patch for the case of d being empty was correct, but the other part of that patch was not correct (as it never allowed partial matches even at the end of the 16-byte operand). Nor was the code before the previous patch correct for the case of d nonempty, as it would always have allowed partial matches at the end of s. Fix with a partial revert of my previous change, combined with inserting a check for the special case of s having maximum length to determine where it is necessary to check for matches. In the added test, test 1 is for the case of empty strings, which failed before my 2017 patch, test 2 is for the bug introduced by my 2017 patch and test 3 deals with the case where a match of an initial segment at the end of the string is not valid when the string ends before the end of the 16-byte operand (that is, the case that would be broken by a simple revert of the non-empty-string part of my 2017 patch). Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/ops_sse.h | 4 ++-- tests/tcg/i386/Makefile.target | 3 +++ tests/tcg/i386/test-i386-pcmpistri.c | 33 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-pcmpistri.c diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 01d6017412..14f2b16abd 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2089,10 +2089,10 @@ static inline unsigned pcmpxstrx(CPUX86State *env, = Reg *d, Reg *s, res =3D (2 << upper) - 1; break; } - for (j =3D valids - validd; j >=3D 0; j--) { + for (j =3D valids =3D=3D upper ? valids : valids - validd; j >=3D = 0; j--) { res <<=3D 1; v =3D 1; - for (i =3D validd; i >=3D 0; i--) { + for (i =3D MIN(valids - j, validd); i >=3D 0; i--) { v &=3D (pcmp_val(s, ctrl, i + j) =3D=3D pcmp_val(d, ctrl, = i)); } res |=3D v; diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index 43ee2e181e..de5a3a275f 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -10,6 +10,9 @@ ALL_X86_TESTS=3D$(I386_SRCS:.c=3D) SKIP_I386_TESTS=3Dtest-i386-ssse3 X86_64_TESTS:=3D$(filter test-i386-ssse3, $(ALL_X86_TESTS)) =20 +test-i386-pcmpistri: CFLAGS +=3D -msse4.2 +test-i386-pcmpistri: QEMU_OPTS +=3D -cpu max + # # hello-i386 is a barebones app # diff --git a/tests/tcg/i386/test-i386-pcmpistri.c b/tests/tcg/i386/test-i38= 6-pcmpistri.c new file mode 100644 index 0000000000..37cb56d669 --- /dev/null +++ b/tests/tcg/i386/test-i386-pcmpistri.c @@ -0,0 +1,33 @@ +/* Test pcmpistri instruction. */ + +#include +#include + +union u { + __m128i x; + unsigned char uc[16]; +}; + +union u s0 =3D { .uc =3D { 0 } }; +union u s1 =3D { .uc =3D "abcdefghijklmnop" }; +union u s2 =3D { .uc =3D "bcdefghijklmnopa" }; +union u s3 =3D { .uc =3D "bcdefghijklmnab" }; + +int +main(void) +{ + int ret =3D 0; + if (_mm_cmpistri(s0.x, s0.x, 0x4c) !=3D 15) { + printf("FAIL: pcmpistri test 1\n"); + ret =3D 1; + } + if (_mm_cmpistri(s1.x, s2.x, 0x4c) !=3D 15) { + printf("FAIL: pcmpistri test 2\n"); + ret =3D 1; + } + if ("%d\n", _mm_cmpistri(s1.x, s3.x, 0x4c) !=3D 16) { + printf("FAIL: pcmpistri test 3\n"); + ret =3D 1; + } + return ret; +} --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907355; cv=none; d=zohomail.com; s=zohoarc; b=bhdULPiEPoOYeB+M930EYunnhK9G18NplAE8z9z6zo72p3K+ya2K9vcJGklj7mY/zW1DkP5de2/6rMNpwBn3O40EKnQFj/0HjbwVjP672bKsI5Sxh7E7R7r08JytN8B0edyyUmNGBGFZvTlRdgyRbACvl+6dckWnizah7mlWBd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907355; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0jZGAntJLVHn8I7RUPheuCFxoZHnkKpJXX7J1SFS5TQ=; b=gZZOZIyKLpprm//LcTjrxGANeK1v/iMNEvMprOva/t+ATpkpPZGZZdZKTOa11OwWYQakXALABdv82HFUK79Q3gQ7rOdvdNNAPCL7BRcirubq0inJ4PuzfMMjMRE63Cylm3ab0M8qRXiRBqFOrBUnImqwHnvE7Z9Ur8dtCf7bYe0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907355440543.6661169713583; Thu, 11 Jun 2020 13:29:15 -0700 (PDT) Received: from localhost ([::1]:55098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTp4-0003sw-5S for importer@patchew.org; Thu, 11 Jun 2020 16:29:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAE-0001YI-Hx for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:02 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:29765 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAC-0001Ne-NQ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-qKmKlUh4PNGXRaDQk-g0lw-1; Thu, 11 Jun 2020 15:46:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCDDC8B8C60; Thu, 11 Jun 2020 19:46:54 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AE8960CC0; Thu, 11 Jun 2020 19:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904819; 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=0jZGAntJLVHn8I7RUPheuCFxoZHnkKpJXX7J1SFS5TQ=; b=Ri4pwHIOIGruvFY0c6OVW/aIDU5whe3uB9Qot5K7V1ObiQCft+LF0BrOJf+IoP1DkvoJ7i WaUxYDkwOWUuDA4XqsJibkPj2rplJtXe9gUN0WAuFcGhWRqk1cAqTDAIP7yidyG2bBrs3z Zbu8i0C33ZYrzIC3COrSqA6zZMqkPIg= X-MC-Unique: qKmKlUh4PNGXRaDQk-g0lw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 083/115] sysemu/accel: Restrict machine methods to system-mode Date: Thu, 11 Jun 2020 15:44:17 -0400 Message-Id: <20200611194449.31468-84-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , Roman Bolshakov , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Restrict init_machine(), setup_post() and has_memory() to system-mode. Reviewed-by: Edgar E. Iglesias Reviewed-by: Cornelia Huck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Roman Bolshakov Message-Id: <20200526172427.17460-2-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- include/sysemu/accel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 47e5788530..e08b8ab8fa 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -37,10 +37,12 @@ typedef struct AccelClass { /*< public >*/ =20 const char *name; +#ifndef CONFIG_USER_ONLY int (*init_machine)(MachineState *ms); void (*setup_post)(MachineState *ms, AccelState *accel); bool (*has_memory)(MachineState *ms, AddressSpace *as, hwaddr start_addr, hwaddr size); +#endif bool *allowed; /* * Array of global properties that would be applied when specific --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907931; cv=none; d=zohomail.com; s=zohoarc; b=MPvKmK66atosKaRhB1r5hmGvKhxAgi5RIjnyR/Hr+6rnKYlJk4TxZVUGpTF1OAWocUdfTA4ICVOlp+NFo8HcyS3k9FTs8BSpxU7am03mx7Xl9WaTGFmgE9eJkUHl0POSBtUj4QJWL1wNDCH/7ec1BTFfcA7jp2erMBUlPGSx9EY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907931; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mMek70LY8Rj0ZZiNjor7IwNclThH77KDPR4GCGts4/Q=; b=nb0bClRpgRxZLnvPt6T3PnbevbJWwsyxhw3CMzyj9adY0lG+wokPufkwaHoGQRzpNcXYeEiLqT0ZOaQN3gA1DSdYB9qFS2c76A6G06CZUmdlGeTMRcksP2f7lY8MCz6HHx6iXV3eV1mgqIFFilQyBBPvytcoX3zHOoZhkSSJSnQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190793130616.049070009362254; Thu, 11 Jun 2020 13:38:51 -0700 (PDT) Received: from localhost ([::1]:59028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTyM-00030O-2m for importer@patchew.org; Thu, 11 Jun 2020 16:38:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAF-0001a3-G0 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20617 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAD-0001Ny-MK for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-9R0u5TOQOPqNeepIvRS6jQ-1; Thu, 11 Jun 2020 15:46:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C952845F29; Thu, 11 Jun 2020 19:46:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0610260CC0; Thu, 11 Jun 2020 19:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904820; 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=mMek70LY8Rj0ZZiNjor7IwNclThH77KDPR4GCGts4/Q=; b=YNoZw8SkQ2PwmIbrYCfzUAGbG30v2Xy092662sVbXBfner7W3Xfc+P3XhZkO78cBNcFO+U Uh5IUrzelHDuSpgMnsk2bHGl8VrDS8V8jl3zDK/2aJSgRaagNRPadcg3pO6yhilIDCgN9L mwEwDdYd5v5n8GQyzi0GtVSqDfmr8Zk= X-MC-Unique: 9R0u5TOQOPqNeepIvRS6jQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 084/115] sysemu/tcg: Only declare tcg_allowed when TCG is available Date: Thu, 11 Jun 2020 15:44:18 -0400 Message-Id: <20200611194449.31468-85-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 When TCG is not available, the tcg_allowed variable does not exist. Reviewed-by: Edgar E. Iglesias Reviewed-by: Cornelia Huck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200526172427.17460-3-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- include/sysemu/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h index 7d116d2e80..d9d3ca8559 100644 --- a/include/sysemu/tcg.h +++ b/include/sysemu/tcg.h @@ -8,9 +8,9 @@ #ifndef SYSEMU_TCG_H #define SYSEMU_TCG_H =20 -extern bool tcg_allowed; void tcg_exec_init(unsigned long tb_size); #ifdef CONFIG_TCG +extern bool tcg_allowed; #define tcg_enabled() (tcg_allowed) #else #define tcg_enabled() 0 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908544; cv=none; d=zohomail.com; s=zohoarc; b=IpZYD2jHie6M4zM/Y0gYd3/PH3ouH8KMRi23ZvMVvzVM8tQR3EnLMFH6jivtKwZDoy+nl+QrBHK5Aa0OaayKE2bKtr6vP3B5FxKRNQE+xZu0osIM3kwUsxBB/zo31MkLEgnd4QayGZNV5ZuMpo3tth7g5lYEpx3nrJrYKhvxndM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LNt5J3B5SyxBKUNcwB+7h6Tk/wi7DwPIja8T9RRLV2s=; b=WvTAGyrf1Byvs/Hr4ReiE1OOQMEkh18ohb8Vly6vJ8bTCvxp79QCxpgu8GdQC3KRtBrp4WlFbaHwxxmXlmpe1x1uOYtzX5eUAudemwjn6I0gwPwZVG0hZbXtGaPWHXSZhE/m6O1Onuoe0lnUeZodAE6V/Zl0QIknpD/C9SSr/B4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908544531229.3320381220458; Thu, 11 Jun 2020 13:49:04 -0700 (PDT) Received: from localhost ([::1]:35122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU8F-0003Ig-4N for importer@patchew.org; Thu, 11 Jun 2020 16:49:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAE-0001XD-1H for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:02 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48014 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAC-0001NM-4D for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-fPdDTtdYMoS-3w7ak-akuQ-1; Thu, 11 Jun 2020 15:46:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C9918B8C61; Thu, 11 Jun 2020 19:46:56 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89F8060CC0; Thu, 11 Jun 2020 19:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904819; 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=LNt5J3B5SyxBKUNcwB+7h6Tk/wi7DwPIja8T9RRLV2s=; b=IuE+WBuSNoXOGDqIgTBfG2DQqT/lhjhbxbHjTj7gIvP1AXz6/0C9FJeGlV9tzujfS7gw0k BtdbwnfJ0IG74ndGpLxpkBWa+OxpfsrE8Gw3HkiHhgmAeUWKLUPltoWCli2xXvASLDir7q qCxuIlZPOsEq5T9XZxeyyGMeTE90ufQ= X-MC-Unique: fPdDTtdYMoS-3w7ak-akuQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 085/115] sysemu/hvf: Only declare hvf_allowed when HVF is available Date: Thu, 11 Jun 2020 15:44:19 -0400 Message-Id: <20200611194449.31468-86-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , Roman Bolshakov , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 When HVF is not available, the hvf_allowed variable does not exist. Reviewed-by: Edgar E. Iglesias Reviewed-by: Cornelia Huck Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Roman Bolshakov Message-Id: <20200526172427.17460-4-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- include/sysemu/hvf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index d211e808e9..fe95743124 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -18,7 +18,6 @@ #include "exec/memory.h" #include "sysemu/accel.h" =20 -extern bool hvf_allowed; #ifdef CONFIG_HVF #include #include @@ -26,11 +25,12 @@ extern bool hvf_allowed; #include "target/i386/cpu.h" uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); +extern bool hvf_allowed; #define hvf_enabled() (hvf_allowed) -#else +#else /* !CONFIG_HVF */ #define hvf_enabled() 0 #define hvf_get_supported_cpuid(func, idx, reg) 0 -#endif +#endif /* !CONFIG_HVF */ =20 /* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908720; cv=none; d=zohomail.com; s=zohoarc; b=ZagBY1I1ufweb3M8M2rPMkjDraWHTcZkhLc0vpZqBQASiW1QlAqcwDlrbpOlXGYn3R240ydztpnDal4JY5EUgmuQ3vyJKfQiWFxdCaF/kPAUALd4vmTv7qkGPBGxKVSv1AmwuzeIm67XsXubRsEa1MCabgv7LxKgpY5oHEElGGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908720; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eYVHpNxxw7MWY152CHc9nNx671yGuicGgwNx49IwhrA=; b=Pc5PDgfasZqFVTOD/7wvH0xAgd2HpH/22HKm03mT3zMpR5zzQTNK57w0D7XfcfhfMf/3SstVGGSTJFM49KXrjJEcj5+oCR38dCRsLDB4ntpF/zHQF60bBKMJNBRRJEaT+QXgR47vRgJ3ssvLfiEMBTQYRyPw5XymsxSKzPZI89o= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908720323754.2371652139819; Thu, 11 Jun 2020 13:52:00 -0700 (PDT) Received: from localhost ([::1]:45026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUB5-0008G8-44 for importer@patchew.org; Thu, 11 Jun 2020 16:51:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAt-0002Uk-IX for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44702 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAn-0001Us-CE for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-sKt29ZECPAS8MPB9SmrTjQ-1; Thu, 11 Jun 2020 15:46:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA6561005512; Thu, 11 Jun 2020 19:46:56 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A0A560CC0; Thu, 11 Jun 2020 19:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904856; 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=eYVHpNxxw7MWY152CHc9nNx671yGuicGgwNx49IwhrA=; b=Gbjuw9o89FROTRw/vXHWEZ/yDpHG9SnJbyXi+/EuUEluByAA9J43cspADtOZp+Jjmj1P7W I+fqsTY1wJxtrS62yHifCEPr76VtVIC2GizwIcnJpcP5YbBSEEs758vO9e0XWHRJGgIs/3 +Tdn08BYD5quiW/ZmNjrIfYVJLV/9w8= X-MC-Unique: sKt29ZECPAS8MPB9SmrTjQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 086/115] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode Date: Thu, 11 Jun 2020 15:44:20 -0400 Message-Id: <20200611194449.31468-87-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 The code related to PPC Virtual Hypervisor is pointless in user-mode. Acked-by: David Gibson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200526172427.17460-5-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- target/ppc/cpu.h | 4 ++-- target/ppc/kvm_ppc.h | 22 +++++++++++----------- target/ppc/translate_init.inc.c | 4 ++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 1988b436cb..e7d382ac10 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1202,6 +1202,7 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr); PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr); PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc); =20 +#ifndef CONFIG_USER_ONLY struct PPCVirtualHypervisorClass { InterfaceClass parent; void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); @@ -1215,10 +1216,8 @@ struct PPCVirtualHypervisorClass { void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t p= te1); void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry); target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp); -#ifndef CONFIG_USER_ONLY void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); -#endif }; =20 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor" @@ -1230,6 +1229,7 @@ struct PPCVirtualHypervisorClass { #define PPC_VIRTUAL_HYPERVISOR_GET_CLASS(obj) \ OBJECT_GET_CLASS(PPCVirtualHypervisorClass, (obj), \ TYPE_PPC_VIRTUAL_HYPERVISOR) +#endif /* CONFIG_USER_ONLY */ =20 void ppc_cpu_do_interrupt(CPUState *cpu); bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index fcaf745516..701c0c262b 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -280,6 +280,17 @@ static inline bool kvmppc_has_cap_spapr_vfio(void) return false; } =20 +static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, + hwaddr ptex, int n) +{ + abort(); +} + +static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t = pte1) +{ + abort(); +} + #endif /* !CONFIG_USER_ONLY */ =20 static inline bool kvmppc_has_cap_epr(void) @@ -310,17 +321,6 @@ static inline int kvmppc_load_htab_chunk(QEMUFile *f, = int fd, uint32_t index, abort(); } =20 -static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, - hwaddr ptex, int n) -{ - abort(); -} - -static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t = pte1) -{ - abort(); -} - static inline bool kvmppc_has_cap_fixup_hcalls(void) { abort(); diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 38cb773ab4..a40888411c 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10942,16 +10942,20 @@ static const TypeInfo ppc_cpu_type_info =3D { .class_init =3D ppc_cpu_class_init, }; =20 +#ifndef CONFIG_USER_ONLY static const TypeInfo ppc_vhyp_type_info =3D { .name =3D TYPE_PPC_VIRTUAL_HYPERVISOR, .parent =3D TYPE_INTERFACE, .class_size =3D sizeof(PPCVirtualHypervisorClass), }; +#endif =20 static void ppc_cpu_register_types(void) { type_register_static(&ppc_cpu_type_info); +#ifndef CONFIG_USER_ONLY type_register_static(&ppc_vhyp_type_info); +#endif } =20 type_init(ppc_cpu_register_types) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907682; cv=none; d=zohomail.com; s=zohoarc; b=Inj3CvWsYI/60g+SzofEUF6I+yx2gB3h3+csjGU0kA281T6XV6ZY2veKoui1Rw+/XdxmYOBcDdis5qTeRFz6xcxXn9iiEJSRO/CXyXKNnQKdNntTAQ5wV/XZ6uH2jgwe3soCQBP9i8d9K2zapiN6auNZ69sySfzIdzjrKmvav9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CqSVqjnl4aUpOYRqUchj6CeSEWEGszyemmeLF9cKaks=; b=h/GCah9co3cGeheatRj6U1W37vDCxvlyPnRTfGxRby4fLrFJxPHnF9bmTnyvii8dBDUUjCps7/1sAgrmEHgMLdJHw7N/NNw7ReeuNqiDlxGJHTO/xpuG69M9dKeKLtRoVFNOvH3M9grHWOQB8+3Q48c2OQyGj3k6VPKYQG2h5MU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907682209173.34656296887965; Thu, 11 Jun 2020 13:34:42 -0700 (PDT) Received: from localhost ([::1]:43648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTuK-0003Im-VL for importer@patchew.org; Thu, 11 Jun 2020 16:34:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAO-0001rS-BF for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:12 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20514 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAM-0001Pq-5e for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-_u2DCYnkM8iXmsLkWI6ZNw-1; Thu, 11 Jun 2020 15:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49F84461; Thu, 11 Jun 2020 19:46:57 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03FF760CC0; Thu, 11 Jun 2020 19:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904829; 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=CqSVqjnl4aUpOYRqUchj6CeSEWEGszyemmeLF9cKaks=; b=KZSpiFue4OZ7gIJHxlQwB2KIjgf2ZMuIe1oDQxUleJWtWK1MAsztNyB1lVoQLS43nD6i15 LlIt4SDfaUTzIAzgE/JN1BS4M2uC19XMGU69jqMyQBkWMpLJcgY8MGF5tQouogHBTIodJI uIhGkmk9yZepJ+TcHqewzZZWPaJfW5k= X-MC-Unique: _u2DCYnkM8iXmsLkWI6ZNw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 087/115] i386: hvf: Move HVFState definition into hvf Date: Thu, 11 Jun 2020 15:44:21 -0400 Message-Id: <20200611194449.31468-88-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov "sysemu/hvf.h" is intended for inclusion in generic code. However it also contains several hvf definitions and declarations, including HVFState that are used only inside "hvf.c". "hvf-i386.h" would be more appropriate place to define HVFState as it's only included by "hvf.c" and "x86_task.c". Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-2-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- include/sysemu/hvf.h | 37 ------------------------------------- target/i386/hvf/hvf-i386.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index fe95743124..644bdfc722 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -15,8 +15,6 @@ =20 #include "cpu.h" #include "qemu/bitops.h" -#include "exec/memory.h" -#include "sysemu/accel.h" =20 #ifdef CONFIG_HVF #include @@ -32,41 +30,6 @@ extern bool hvf_allowed; #define hvf_get_supported_cpuid(func, idx, reg) 0 #endif /* !CONFIG_HVF */ =20 -/* hvf_slot flags */ -#define HVF_SLOT_LOG (1 << 0) - -typedef struct hvf_slot { - uint64_t start; - uint64_t size; - uint8_t *mem; - int slot_id; - uint32_t flags; - MemoryRegion *region; -} hvf_slot; - -typedef struct hvf_vcpu_caps { - uint64_t vmx_cap_pinbased; - uint64_t vmx_cap_procbased; - uint64_t vmx_cap_procbased2; - uint64_t vmx_cap_entry; - uint64_t vmx_cap_exit; - uint64_t vmx_cap_preemption_timer; -} hvf_vcpu_caps; - -typedef struct HVFState { - AccelState parent; - hvf_slot slots[32]; - int num_slots; - - hvf_vcpu_caps *hvf_caps; -} HVFState; -extern HVFState *hvf_state; - -void hvf_set_phys_mem(MemoryRegionSection *, bool); -void hvf_handle_io(CPUArchState *, uint16_t, void *, - int, int, int); -hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); - /* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported= by * the host CPU. Use hvf_enabled() after this to get the result. */ void hvf_disable(int disable); diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h index fbe4a350c5..ef20c73eca 100644 --- a/target/i386/hvf/hvf-i386.h +++ b/target/i386/hvf/hvf-i386.h @@ -16,6 +16,7 @@ #ifndef HVF_I386_H #define HVF_I386_H =20 +#include "sysemu/accel.h" #include "sysemu/hvf.h" #include "cpu.h" #include "x86.h" @@ -35,6 +36,40 @@ struct hvf_state { uint64_t mem_quota; }; =20 +/* hvf_slot flags */ +#define HVF_SLOT_LOG (1 << 0) + +typedef struct hvf_slot { + uint64_t start; + uint64_t size; + uint8_t *mem; + int slot_id; + uint32_t flags; + MemoryRegion *region; +} hvf_slot; + +typedef struct hvf_vcpu_caps { + uint64_t vmx_cap_pinbased; + uint64_t vmx_cap_procbased; + uint64_t vmx_cap_procbased2; + uint64_t vmx_cap_entry; + uint64_t vmx_cap_exit; + uint64_t vmx_cap_preemption_timer; +} hvf_vcpu_caps; + +typedef struct HVFState { + AccelState parent; + hvf_slot slots[32]; + int num_slots; + + hvf_vcpu_caps *hvf_caps; +} HVFState; +extern HVFState *hvf_state; + +void hvf_set_phys_mem(MemoryRegionSection *, bool); +void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int); +hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); + #ifdef NEED_CPU_H /* Functions exported to host specific mode */ =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908869; cv=none; d=zohomail.com; s=zohoarc; b=mzJzmOoeDqllYA2OXfi6Xyl1vGUuBUIW2Q8UAR+MR1ooa2VJprJqYKoqCJSHb2fTSqYLL/EJjdJ7QA+XhEqKRCtAmlcJO6bYrfRNCTHgXuWolki3JSyRzHL5epTcZQd6PPK9JqQPS/f7TEjge051Kl99aS5dyiWuKAPtltW8Xas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908869; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pkkl1XmEkm53grcqvOr+ZivD+Z2ANG5k7fTA9QM7cbY=; b=igRgLc4DSvkRE5jmgenEdEx/5xCtBP7b1YoiEQPnAbbXEEWDmmIc9SE2nFujl0S1/rrq0ymHSYCIZC9bD5cnIxoptbJSAQJekMBYrQrvhSWvUNl+2pYck4hAVygu8ikXHbP92cRM/Zj3jWWCu9asaNnucAv6Zk1JnzhnciaU0XA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908869780774.3272857365218; Thu, 11 Jun 2020 13:54:29 -0700 (PDT) Received: from localhost ([::1]:54578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUDU-00050K-J0 for importer@patchew.org; Thu, 11 Jun 2020 16:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAH-0001dA-Hd for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57397 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAD-0001Nt-IX for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-Hsk0Gu9DO_mNoKxNKClXyw-1; Thu, 11 Jun 2020 15:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCF3E8B8C60; Thu, 11 Jun 2020 19:46:57 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6789C60CC0; Thu, 11 Jun 2020 19:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904820; 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=pkkl1XmEkm53grcqvOr+ZivD+Z2ANG5k7fTA9QM7cbY=; b=JhM6h7CLBWWd4VOnjK/0ykovEdl3MUd1892wZcUsLuZF+x0g8cHYtY6zzjVX877PVWiidb 8Fz9nlF8ndL+qkejPjlI4LI7UbnJu0h3MoMQpbewPxE2hlN7FVUFTebR8LSXAsekBHIbzJ uAcfUOSQP+1UnPLs30HuYf6NgRenl3k= X-MC-Unique: Hsk0Gu9DO_mNoKxNKClXyw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 088/115] i386: hvf: Drop useless declarations in sysemu Date: Thu, 11 Jun 2020 15:44:22 -0400 Message-Id: <20200611194449.31468-89-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Roman Bolshakov They're either declared elsewhere or have no use. While at it, rename _hvf_cpu_synchronize_post_init() to do_hvf_cpu_synchronize_post_init(). Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-3-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/hvf.h | 22 ---------------------- target/i386/hvf/hvf.c | 7 ++++--- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index 644bdfc722..2af32e505e 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -30,35 +30,13 @@ extern bool hvf_allowed; #define hvf_get_supported_cpuid(func, idx, reg) 0 #endif /* !CONFIG_HVF */ =20 -/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported= by - * the host CPU. Use hvf_enabled() after this to get the result. */ -void hvf_disable(int disable); - -/* Returns non-0 if the host CPU supports the VMX "unrestricted guest" fea= ture - * which allows the virtual CPU to directly run in "real mode". If true, t= his - * allows QEMU to run several vCPU threads in parallel (see cpus.c). Other= wise, - * only a a single TCG thread can run, and it will call HVF to run the cur= rent - * instructions, except in case of "real mode" (paging disabled, typically= at - * boot time), or MMIO operations. */ - -int hvf_sync_vcpus(void); - int hvf_init_vcpu(CPUState *); int hvf_vcpu_exec(CPUState *); -int hvf_smp_cpu_exec(CPUState *); void hvf_cpu_synchronize_state(CPUState *); void hvf_cpu_synchronize_post_reset(CPUState *); void hvf_cpu_synchronize_post_init(CPUState *); -void _hvf_cpu_synchronize_post_init(CPUState *, run_on_cpu_data); - void hvf_vcpu_destroy(CPUState *); -void hvf_raise_event(CPUState *); -/* void hvf_reset_vcpu_state(void *opaque); */ void hvf_reset_vcpu(CPUState *); -void vmx_update_tpr(CPUState *); -void update_apic_tpr(CPUState *); -int hvf_put_registers(CPUState *); -void vmx_clear_int_window_exiting(CPUState *cpu); =20 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf") =20 diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index d72543dc31..9ccdb7e7c7 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -251,7 +251,7 @@ void vmx_update_tpr(CPUState *cpu) } } =20 -void update_apic_tpr(CPUState *cpu) +static void update_apic_tpr(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); int tpr =3D rreg(cpu->hvf_fd, HV_X86_TPR) >> 4; @@ -312,7 +312,8 @@ void hvf_cpu_synchronize_post_reset(CPUState *cpu_state) run_on_cpu(cpu_state, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NU= LL); } =20 -void _hvf_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg) +static void do_hvf_cpu_synchronize_post_init(CPUState *cpu, + run_on_cpu_data arg) { CPUState *cpu_state =3D cpu; hvf_put_registers(cpu_state); @@ -321,7 +322,7 @@ void _hvf_cpu_synchronize_post_init(CPUState *cpu, run_= on_cpu_data arg) =20 void hvf_cpu_synchronize_post_init(CPUState *cpu_state) { - run_on_cpu(cpu_state, _hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); + run_on_cpu(cpu_state, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NUL= L); } =20 static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept= _qual) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908058; cv=none; d=zohomail.com; s=zohoarc; b=BdypqF7d0phE8WI8sTbzCFSOz4nokK/FESdbL5DnJQnRMznfjXWmkyvly3hj31sIscT39NNv5K+DS5zIYHA7ynS4MZxwDe5ug79JB7h0YM6FF/ZXHB6VGVU9csuAj1z/u1gafr398UoRIdId7crbuIWna7xuTRUKrJjvF9v5LoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908058; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5SORuWqQy0re94mGrihKTtIfRZNWse6QdmhvjhWiRng=; b=aB6w2ZJJe1hpVBhkLXGlFHkYv2J6EH9+1NMSXNsvnq7w5e75mHYZdHauG25aaPoQKXhhC86E2wM3UuGO2IztO8Q3RX8K/l7Gzf8JwvMdv5fdM/in172BbUWzHza/XqXdT1FrI/nVzzCZKxIgPFb5k4uKd1Mo5z3u81rv7WWLy2E= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908058605505.4253246523401; Thu, 11 Jun 2020 13:40:58 -0700 (PDT) Received: from localhost ([::1]:39092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU0P-0006jJ-Ev for importer@patchew.org; Thu, 11 Jun 2020 16:40:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAI-0001ga-Vc for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54925 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAH-0001On-3u for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-tVQlcYgKNZ2IEquQrzAwCw-1; Thu, 11 Jun 2020 15:46:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BC7E1800D41; Thu, 11 Jun 2020 19:46:58 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA82F60CC0; Thu, 11 Jun 2020 19:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904824; 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=5SORuWqQy0re94mGrihKTtIfRZNWse6QdmhvjhWiRng=; b=Vlcx/JYFnUb2IN8RVzk8dujD2M36l0Debt1486efV7k6edNymAt4vTSZN/u7ABE02/qD2E 3a88Fvzjuo1UL2xM9HT+EGh/ZSJPos20aljRE1og4IZPbpNGoi2WqJbBCyJPpJvAOI/SI0 +DN0PoMFnYPIPATCrU+4YQAa1ij51xQ= X-MC-Unique: tVQlcYgKNZ2IEquQrzAwCw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 089/115] i386: hvf: Drop unused variable Date: Thu, 11 Jun 2020 15:44:23 -0400 Message-Id: <20200611194449.31468-90-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Roman Bolshakov Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-5-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/x86.h | 1 - 1 file changed, 1 deletion(-) diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index c95d5b2116..56fcde13c6 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -293,7 +293,6 @@ typedef struct lazy_flags { =20 /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { - int interruptable; uint64_t fetch_rip; uint64_t rip; struct x86_register regs[16]; --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907565; cv=none; d=zohomail.com; s=zohoarc; b=j4ojpeTUBUD+b3kQ7dy2AacqBNk53T8WP5pLTZs4bIhV771iaqKaA8+pU0WT09o20YDyKnAfB08AwTtNXJhYJRW5ZBEXvkSn3e5A36NGIuai8kKZwOf8fDWdDf0PFxzlMTi65kqMVjiYBhYIH1WzqP/M3FwlGRb6wgtKtUSI1/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907565; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FtYtVXqdNbMGR1ItVe17GssPsFy28A6rW/XM7goSGcY=; b=V55+MrqmAAn3144kSvQLfN+30ST2kw75mizrkcLg1pCd6wUe/DVqWMWU8FziswBS7TpMg4u1OuapMg1Cnq9fSQLpRXQvv5fTZfd/cWIJUdr8Lorqb12/S/TnKgA0/LSp1cQvFPKWFiS6wCXDjiv1WbStRtRfgZ77y92Qzf9GmSg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907565451950.7562752736102; Thu, 11 Jun 2020 13:32:45 -0700 (PDT) Received: from localhost ([::1]:35406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTsS-0007aX-7Q for importer@patchew.org; Thu, 11 Jun 2020 16:32:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAH-0001dm-Pm for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37243 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAF-0001OZ-Rj for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-BKLzjKv3NX2L4q-mRakpQQ-1; Thu, 11 Jun 2020 15:47:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6068D107ACCD; Thu, 11 Jun 2020 19:46:59 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAE6210013D0; Thu, 11 Jun 2020 19:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904823; 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=FtYtVXqdNbMGR1ItVe17GssPsFy28A6rW/XM7goSGcY=; b=XpDgbJZDBr6t3714YXq1mfsPjRm/+RpvISJ9/u8Bz7GN3VcB/ZmDjQNEOkdQV/Ti2nvPms iCxtZ26+UXBggeka2AfM3OVOvNY6hlmW92tAUs/uTFCtrAhtjG76NieJzWu1hYgN7P7Ivd nuA8WfQCsXshae9chdtnvC8fz5pt0/w= X-MC-Unique: BKLzjKv3NX2L4q-mRakpQQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 090/115] i386: hvf: Use ins_len to advance IP Date: Thu, 11 Jun 2020 15:44:24 -0400 Message-Id: <20200611194449.31468-91-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Roman Bolshakov There's no need to read VMCS twice, instruction length is already available in ins_len. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-6-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/hvf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 9ccdb7e7c7..8ff1d25521 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -871,7 +871,7 @@ int hvf_vcpu_exec(CPUState *cpu) } else { simulate_wrmsr(cpu); } - RIP(env) +=3D rvmcs(cpu->hvf_fd, VMCS_EXIT_INSTRUCTION_LENGTH); + RIP(env) +=3D ins_len; store_regs(cpu); break; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591909163; cv=none; d=zohomail.com; s=zohoarc; b=MVhrtkv1gDq4ySQ/S7bwBMMQPpwUVEx/q4//CvanEewS25YeH8EUk+bDBTwjCelEqPIfB21QRdplt59MJw/IfiUgYxq3q1wKgUKn+KQR81sdPs0NFziA35TVb8CY26FIGygIspl0q24CNH9n5WBY9xaaiD8JgSR6rU2O1EB3FuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=akk/FE9CRg5BGr6grrg/fhbWnvUGM+OXlldTVi8enSA=; b=Poz40lAQZQSC1f8WuqgsWCLBfb0YbZfYm/Xdg/yUp2rtiXG9uimSifcDa3VGunlyMObig+FKSMc5q2w58qf0/ssG4uxLNNgUPLPJtt2kwQBpauelrduX8E0W7F95oKWC5zhfSXKy8u1FzGzUDsNQTKAbjE+1tkVlaoh87k439FA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919091638071009.2435536541878; Thu, 11 Jun 2020 13:59:23 -0700 (PDT) Received: from localhost ([::1]:42878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUIE-0003bp-8B for importer@patchew.org; Thu, 11 Jun 2020 16:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAJ-0001hx-Hd for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:07 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:49803 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAG-0001Oe-AI for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-DKbvb5ZuNyG8Yu2-wC1NuQ-1; Thu, 11 Jun 2020 15:47:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D86A1940921; Thu, 11 Jun 2020 19:47:00 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90D4410013D7; Thu, 11 Jun 2020 19:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904823; 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=akk/FE9CRg5BGr6grrg/fhbWnvUGM+OXlldTVi8enSA=; b=iJMwrMDz6XnivhM/BPj6oY4pn6XLPN+wwZiZtD5FKLpRnAorcHl/E0qdxUozLAx3quY4KP yJmgXL25hRIglfGsGBiUeD6RugpemmlJgJuc5Kt25WQX3GYQkBM1sVxhxK8ErBNTDnQhGW yEkdtwraC+XmUNlXyh5ofTGdLWu1p80= X-MC-Unique: DKbvb5ZuNyG8Yu2-wC1NuQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 091/115] i386: hvf: Use IP from CPUX86State Date: Thu, 11 Jun 2020 15:44:25 -0400 Message-Id: <20200611194449.31468-92-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Roman Bolshakov Drop and replace rip field from HVFX86EmulatorState in favor of eip from common CPUX86State. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-7-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/hvf.c | 6 +-- target/i386/hvf/x86.h | 3 -- target/i386/hvf/x86_decode.c | 6 +-- target/i386/hvf/x86_emu.c | 86 ++++++++++++++++++------------------ target/i386/hvf/x86_task.c | 4 +- 5 files changed, 51 insertions(+), 54 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 8ff1d25521..45ae55dd27 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -797,7 +797,7 @@ int hvf_vcpu_exec(CPUState *cpu) } else { RAX(env) =3D (uint64_t)val; } - RIP(env) +=3D ins_len; + env->eip +=3D ins_len; store_regs(cpu); break; } else if (!string && !in) { @@ -871,7 +871,7 @@ int hvf_vcpu_exec(CPUState *cpu) } else { simulate_wrmsr(cpu); } - RIP(env) +=3D ins_len; + env->eip +=3D ins_len; store_regs(cpu); break; } @@ -907,7 +907,7 @@ int hvf_vcpu_exec(CPUState *cpu) error_report("Unrecognized CR %d", cr); abort(); } - RIP(env) +=3D ins_len; + env->eip +=3D ins_len; store_regs(cpu); break; } diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 56fcde13c6..e3ab7c5137 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -294,7 +294,6 @@ typedef struct lazy_flags { /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { uint64_t fetch_rip; - uint64_t rip; struct x86_register regs[16]; struct x86_reg_flags rflags; struct lazy_flags lflags; @@ -302,8 +301,6 @@ struct HVFX86EmulatorState { }; =20 /* useful register access macros */ -#define RIP(cpu) (cpu->hvf_emul->rip) -#define EIP(cpu) ((uint32_t)cpu->hvf_emul->rip) #define RFLAGS(cpu) (cpu->hvf_emul->rflags.rflags) #define EFLAGS(cpu) (cpu->hvf_emul->rflags.eflags) =20 diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c index 77c346605f..a590088f54 100644 --- a/target/i386/hvf/x86_decode.c +++ b/target/i386/hvf/x86_decode.c @@ -75,7 +75,7 @@ static inline uint64_t decode_bytes(CPUX86State *env, str= uct x86_decode *decode, VM_PANIC_EX("%s invalid size %d\n", __func__, size); break; } - target_ulong va =3D linear_rip(env_cpu(env), RIP(env)) + decode->len; + target_ulong va =3D linear_rip(env_cpu(env), env->eip) + decode->len; vmx_read_mem(env_cpu(env), &val, va, size); decode->len +=3D size; =20 @@ -1771,7 +1771,7 @@ void calc_modrm_operand32(CPUX86State *env, struct x8= 6_decode *decode, ptr +=3D get_sib_val(env, decode, &seg); } else if (!decode->modrm.mod && 5 =3D=3D decode->modrm.rm) { if (x86_is_long_mode(env_cpu(env))) { - ptr +=3D RIP(env) + decode->len; + ptr +=3D env->eip + decode->len; } else { ptr =3D decode->displacement; } @@ -1807,7 +1807,7 @@ void calc_modrm_operand64(CPUX86State *env, struct x8= 6_decode *decode, if (4 =3D=3D rm) { ptr =3D get_sib_val(env, decode, &seg) + offset; } else if (0 =3D=3D mod && 5 =3D=3D rm) { - ptr =3D RIP(env) + decode->len + (int32_t) offset; + ptr =3D env->eip + decode->len + (int32_t) offset; } else { ptr =3D get_reg_val(env, src, decode->rex.rex, decode->rex.b, 8) + (int64_t) offset; diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 92ab815f5d..0efd9f9928 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -267,49 +267,49 @@ static void exec_mov(struct CPUX86State *env, struct = x86_decode *decode) write_val_ext(env, decode->op[0].ptr, decode->op[1].val, decode->operand_size); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_add(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, +, SET_FLAGS_OSZAPC_ADD, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_or(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, |, SET_FLAGS_OSZAPC_LOGIC, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_adc(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, +get_CF(env)+, SET_FLAGS_OSZAPC_ADD, t= rue); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_sbb(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, -get_CF(env)-, SET_FLAGS_OSZAPC_SUB, t= rue); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_and(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, &, SET_FLAGS_OSZAPC_LOGIC, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_sub(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, -, SET_FLAGS_OSZAPC_SUB, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_xor(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, ^, SET_FLAGS_OSZAPC_LOGIC, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_neg(struct CPUX86State *env, struct x86_decode *decode) @@ -332,13 +332,13 @@ static void exec_neg(struct CPUX86State *env, struct = x86_decode *decode) } =20 /*lflags_to_rflags(env);*/ - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_cmp(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, -, SET_FLAGS_OSZAPC_SUB, false); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_inc(struct CPUX86State *env, struct x86_decode *decode) @@ -348,7 +348,7 @@ static void exec_inc(struct CPUX86State *env, struct x8= 6_decode *decode) =20 EXEC_2OP_FLAGS_CMD(env, decode, +1+, SET_FLAGS_OSZAP_ADD, true); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_dec(struct CPUX86State *env, struct x86_decode *decode) @@ -357,13 +357,13 @@ static void exec_dec(struct CPUX86State *env, struct = x86_decode *decode) decode->op[1].val =3D 0; =20 EXEC_2OP_FLAGS_CMD(env, decode, -1-, SET_FLAGS_OSZAP_SUB, true); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_tst(struct CPUX86State *env, struct x86_decode *decode) { EXEC_2OP_FLAGS_CMD(env, decode, &, SET_FLAGS_OSZAPC_LOGIC, false); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_not(struct CPUX86State *env, struct x86_decode *decode) @@ -372,7 +372,7 @@ static void exec_not(struct CPUX86State *env, struct x8= 6_decode *decode) =20 write_val_ext(env, decode->op[0].ptr, ~decode->op[0].val, decode->operand_size); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_movzx(struct CPUX86State *env, struct x86_decode *decode) @@ -392,7 +392,7 @@ void exec_movzx(struct CPUX86State *env, struct x86_dec= ode *decode) decode->op[1].val =3D read_val_ext(env, decode->op[1].ptr, src_op_size= ); write_val_ext(env, decode->op[0].ptr, decode->op[1].val, op_size); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_out(struct CPUX86State *env, struct x86_decode *decode) @@ -416,7 +416,7 @@ static void exec_out(struct CPUX86State *env, struct x8= 6_decode *decode) VM_PANIC("Bad out opcode\n"); break; } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_in(struct CPUX86State *env, struct x86_decode *decode) @@ -452,7 +452,7 @@ static void exec_in(struct CPUX86State *env, struct x86= _decode *decode) break; } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static inline void string_increment_reg(struct CPUX86State *env, int reg, @@ -505,7 +505,7 @@ static void exec_ins(struct CPUX86State *env, struct x8= 6_decode *decode) exec_ins_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_outs_single(struct CPUX86State *env, struct x86_decode *d= ecode) @@ -528,7 +528,7 @@ static void exec_outs(struct CPUX86State *env, struct x= 86_decode *decode) exec_outs_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_movs_single(struct CPUX86State *env, struct x86_decode *d= ecode) @@ -556,7 +556,7 @@ static void exec_movs(struct CPUX86State *env, struct x= 86_decode *decode) exec_movs_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_cmps_single(struct CPUX86State *env, struct x86_decode *d= ecode) @@ -586,7 +586,7 @@ static void exec_cmps(struct CPUX86State *env, struct x= 86_decode *decode) } else { exec_cmps_single(env, decode); } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 =20 @@ -612,7 +612,7 @@ static void exec_stos(struct CPUX86State *env, struct x= 86_decode *decode) exec_stos_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_scas_single(struct CPUX86State *env, struct x86_decode *d= ecode) @@ -638,7 +638,7 @@ static void exec_scas(struct CPUX86State *env, struct x= 86_decode *decode) exec_scas_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_lods_single(struct CPUX86State *env, struct x86_decode *d= ecode) @@ -661,7 +661,7 @@ static void exec_lods(struct CPUX86State *env, struct x= 86_decode *decode) exec_lods_single(env, decode); } =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void simulate_rdmsr(struct CPUState *cpu) @@ -758,7 +758,7 @@ void simulate_rdmsr(struct CPUState *cpu) static void exec_rdmsr(struct CPUX86State *env, struct x86_decode *decode) { simulate_rdmsr(env_cpu(env)); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void simulate_wrmsr(struct CPUState *cpu) @@ -853,7 +853,7 @@ void simulate_wrmsr(struct CPUState *cpu) static void exec_wrmsr(struct CPUX86State *env, struct x86_decode *decode) { simulate_wrmsr(env_cpu(env)); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 /* @@ -909,25 +909,25 @@ static void do_bt(struct CPUX86State *env, struct x86= _decode *decode, int flag) static void exec_bt(struct CPUX86State *env, struct x86_decode *decode) { do_bt(env, decode, 0); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_btc(struct CPUX86State *env, struct x86_decode *decode) { do_bt(env, decode, 1); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_btr(struct CPUX86State *env, struct x86_decode *decode) { do_bt(env, decode, 3); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_bts(struct CPUX86State *env, struct x86_decode *decode) { do_bt(env, decode, 2); - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_shl(struct CPUX86State *env, struct x86_decode *decode) @@ -991,7 +991,7 @@ void exec_shl(struct CPUX86State *env, struct x86_decod= e *decode) =20 exit: /* lflags_to_rflags(env); */ - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_movsx(CPUX86State *env, struct x86_decode *decode) @@ -1014,7 +1014,7 @@ void exec_movsx(CPUX86State *env, struct x86_decode *= decode) =20 write_val_ext(env, decode->op[0].ptr, decode->op[1].val, op_size); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_ror(struct CPUX86State *env, struct x86_decode *decode) @@ -1092,7 +1092,7 @@ void exec_ror(struct CPUX86State *env, struct x86_dec= ode *decode) break; } } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_rol(struct CPUX86State *env, struct x86_decode *decode) @@ -1173,7 +1173,7 @@ void exec_rol(struct CPUX86State *env, struct x86_dec= ode *decode) break; } } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 =20 @@ -1259,7 +1259,7 @@ void exec_rcl(struct CPUX86State *env, struct x86_dec= ode *decode) break; } } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 void exec_rcr(struct CPUX86State *env, struct x86_decode *decode) @@ -1334,7 +1334,7 @@ void exec_rcr(struct CPUX86State *env, struct x86_dec= ode *decode) break; } } - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_xchg(struct CPUX86State *env, struct x86_decode *decode) @@ -1346,7 +1346,7 @@ static void exec_xchg(struct CPUX86State *env, struct= x86_decode *decode) write_val_ext(env, decode->op[1].ptr, decode->op[0].val, decode->operand_size); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static void exec_xadd(struct CPUX86State *env, struct x86_decode *decode) @@ -1355,7 +1355,7 @@ static void exec_xadd(struct CPUX86State *env, struct= x86_decode *decode) write_val_ext(env, decode->op[1].ptr, decode->op[0].val, decode->operand_size); =20 - RIP(env) +=3D decode->len; + env->eip +=3D decode->len; } =20 static struct cmd_handler { @@ -1434,7 +1434,7 @@ void load_regs(struct CPUState *cpu) =20 RFLAGS(env) =3D rreg(cpu->hvf_fd, HV_X86_RFLAGS); rflags_to_lflags(env); - RIP(env) =3D rreg(cpu->hvf_fd, HV_X86_RIP); + env->eip =3D rreg(cpu->hvf_fd, HV_X86_RIP); } =20 void store_regs(struct CPUState *cpu) @@ -1457,20 +1457,20 @@ void store_regs(struct CPUState *cpu) =20 lflags_to_rflags(env); wreg(cpu->hvf_fd, HV_X86_RFLAGS, RFLAGS(env)); - macvm_set_rip(cpu, RIP(env)); + macvm_set_rip(cpu, env->eip); } =20 bool exec_instruction(struct CPUX86State *env, struct x86_decode *ins) { /*if (hvf_vcpu_id(cpu)) - printf("%d, %llx: exec_instruction %s\n", hvf_vcpu_id(cpu), RIP(cpu), + printf("%d, %llx: exec_instruction %s\n", hvf_vcpu_id(cpu), env->eip, decode_cmd_to_string(ins->cmd));*/ =20 if (!_cmd_handler[ins->cmd].handler) { - printf("Unimplemented handler (%llx) for %d (%x %x) \n", RIP(env), + printf("Unimplemented handler (%llx) for %d (%x %x) \n", env->eip, ins->cmd, ins->opcode[0], ins->opcode_len > 1 ? ins->opcode[1] : 0); - RIP(env) +=3D ins->len; + env->eip +=3D ins->len; return true; } =20 diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c index 1daac6cc2b..834baec3ea 100644 --- a/target/i386/hvf/x86_task.c +++ b/target/i386/hvf/x86_task.c @@ -38,7 +38,7 @@ static void save_state_to_tss32(CPUState *cpu, struct x86= _tss_segment32 *tss) CPUX86State *env =3D &x86_cpu->env; =20 /* CR3 and ldt selector are not saved intentionally */ - tss->eip =3D EIP(env); + tss->eip =3D (uint32_t)env->eip; tss->eflags =3D EFLAGS(env); tss->eax =3D EAX(env); tss->ecx =3D ECX(env); @@ -64,7 +64,7 @@ static void load_state_from_tss32(CPUState *cpu, struct x= 86_tss_segment32 *tss) =20 wvmcs(cpu->hvf_fd, VMCS_GUEST_CR3, tss->cr3); =20 - RIP(env) =3D tss->eip; + env->eip =3D tss->eip; EFLAGS(env) =3D tss->eflags | 2; =20 /* General purpose registers */ --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908265; cv=none; d=zohomail.com; s=zohoarc; b=GMOvYpmkm6ZhcqmgVpAdKyvVD46l+zK+bmki9F79PHLHhiP92SH2ZuaQEKJ17zCnt2cSAs6knjuiod1J5DdHk5gc645M2xHLZmQY08T4oFfXBjNyvha2K8l+vE5M7R2z25R6kOIih+zIIB7T2CEl3EB24bYrbd/jAczvDomkpcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908265; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q7QLfxjfd2csDrjuBSLw6r1kZqpug+IOoFmV+B6qm9Q=; b=K+BgjANyw2JrgRuywFK6J8lpZ2Lm/4anDaPeaVGMtpJVY4W0pJhbddkPGhBQb6mLLmbveVjkwL/5PEYGzGonDbBjSz34sf3wcIhDjpO53GUmrXj/U91kpmqmCxOoPqyMIhyzBtRBCVXoqA+EtawjcOCCDMFe+MXe/lKXKELTMHs= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908265894744.5250082792799; Thu, 11 Jun 2020 13:44:25 -0700 (PDT) Received: from localhost ([::1]:47316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU3k-0002Rn-Ik for importer@patchew.org; Thu, 11 Jun 2020 16:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAJ-0001gm-4J for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37596 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAH-0001Om-3M for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-3f8f4-FTP92DUJ1cR5bdqg-1; Thu, 11 Jun 2020 15:47:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB23C91164; Thu, 11 Jun 2020 19:47:00 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E6D710013D7; Thu, 11 Jun 2020 19:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904824; 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=Q7QLfxjfd2csDrjuBSLw6r1kZqpug+IOoFmV+B6qm9Q=; b=QbJrt20b5pWI7G+DRGxCGAtFlbNXYy+y0dRl8Tc4pIh+gNLXKJN+lF8UzgdadmAjTHEDoM G7Ptb/7cXwWSGpsm+I+HVYPss9Jmcb2sUsIjDr8Cz34dq6AqdwXjiKI+kRC0W6tcfsNiD/ RL6i/cV4OkMWkBJOJbZbuWlHDTP1DCc= X-MC-Unique: 3f8f4-FTP92DUJ1cR5bdqg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 092/115] i386: hvf: Drop fetch_rip from HVFX86EmulatorState Date: Thu, 11 Jun 2020 15:44:26 -0400 Message-Id: <20200611194449.31468-93-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov The field is used to print address of instructions that have no parser in decode_invalid(). RIP from VMCS is saved into fetch_rip before decoding starts but it's also saved into env->eip in load_regs(). Therefore env->eip can be used instead of fetch_rip. While at it, correct address printed in decode_invalid(). It prints an address before the unknown instruction. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-8-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 6 ------ target/i386/hvf/x86.h | 1 - target/i386/hvf/x86_decode.c | 3 +-- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 45ae55dd27..416a6fae7c 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -767,8 +767,6 @@ int hvf_vcpu_exec(CPUState *cpu) struct x86_decode decode; =20 load_regs(cpu); - env->hvf_emul->fetch_rip =3D rip; - decode_instruction(env, &decode); exec_instruction(env, &decode); store_regs(cpu); @@ -809,8 +807,6 @@ int hvf_vcpu_exec(CPUState *cpu) struct x86_decode decode; =20 load_regs(cpu); - env->hvf_emul->fetch_rip =3D rip; - decode_instruction(env, &decode); assert(ins_len =3D=3D decode.len); exec_instruction(env, &decode); @@ -915,8 +911,6 @@ int hvf_vcpu_exec(CPUState *cpu) struct x86_decode decode; =20 load_regs(cpu); - env->hvf_emul->fetch_rip =3D rip; - decode_instruction(env, &decode); exec_instruction(env, &decode); store_regs(cpu); diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index e3ab7c5137..411e4b6599 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -293,7 +293,6 @@ typedef struct lazy_flags { =20 /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { - uint64_t fetch_rip; struct x86_register regs[16]; struct x86_reg_flags rflags; struct lazy_flags lflags; diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c index a590088f54..d881542181 100644 --- a/target/i386/hvf/x86_decode.c +++ b/target/i386/hvf/x86_decode.c @@ -29,8 +29,7 @@ =20 static void decode_invalid(CPUX86State *env, struct x86_decode *decode) { - printf("%llx: failed to decode instruction ", env->hvf_emul->fetch_rip= - - decode->len); + printf("%llx: failed to decode instruction ", env->eip); for (int i =3D 0; i < decode->opcode_len; i++) { printf("%x ", decode->opcode[i]); } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907836; cv=none; d=zohomail.com; s=zohoarc; b=eP2KH93bRz+0Vjo3FORlWdGtcozXZRgMEha4G4M6uXRpi6lBx8h52Bd9dRmtM0eqwEIjtwszISPH0bR+ui9zA2xfeFYKgQOh71GFXGdub4IlSqWpwBp0r5Fqfpmhy3ZnvEzsl7eLxHcWJwM/JwSJaNIEBK3qof67qbdOp0kDZL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907836; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mt/mzo7Xjry8W/ngrfH4ZHzjNcs1f2BBM2/k/sxZwoM=; b=cb1GXa/XCZUpuOFTpEg0o5psE3B3fnCaM4Crr9caSIA/MUBF5gQR96sR85fdvXXgWZR7CVLl5IYgDGOxHd2jVnKq5d40mS1ysRbNkinHtN5IETDsJk1kPLHAl9bS6MfsvYbnUcPJfGFzE4Yr7WeNO0f0hY4DtBkCBZBUAJ2TxcI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907836209534.740875493485; Thu, 11 Jun 2020 13:37:16 -0700 (PDT) Received: from localhost ([::1]:52984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTwo-0008SR-TS for importer@patchew.org; Thu, 11 Jun 2020 16:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAQ-0001vi-D7 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:14 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51103 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAM-0001Py-MS for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-DzieUaGuOYeOynBIcw234g-1; Thu, 11 Jun 2020 15:47:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85C75845F2A; Thu, 11 Jun 2020 19:47:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1861010013D7; Thu, 11 Jun 2020 19:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904829; 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=Mt/mzo7Xjry8W/ngrfH4ZHzjNcs1f2BBM2/k/sxZwoM=; b=GP4EoOX9TZhDU3voysGzgeZIc4hxjYTvigBkb98KTp45QKYlCgJ/gniuON/9UwZa63xUrB u8PjPcqYjZMXvjrrp8J8N0QJsvl3vB68IkOUHIG9N2cT2xyNb8its7B14fGC3bOIi0uXYO oCBfoZREB08Ocy0I6FvLSfpXwio+znE= X-MC-Unique: DzieUaGuOYeOynBIcw234g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 093/115] i386: hvf: Drop rflags from HVFX86EmulatorState Date: Thu, 11 Jun 2020 15:44:27 -0400 Message-Id: <20200611194449.31468-94-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov HVFX86EmulatorState carries it's own copy of x86 flags. It can be dropped in favor of eflags in generic CPUX86State. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-9-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 5 ++--- target/i386/hvf/x86.c | 2 +- target/i386/hvf/x86.h | 42 ------------------------------------- target/i386/hvf/x86_emu.c | 6 +++--- target/i386/hvf/x86_flags.c | 24 ++++++++++----------- target/i386/hvf/x86_task.c | 6 +++--- target/i386/hvf/x86hvf.c | 6 +++--- 7 files changed, 24 insertions(+), 67 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 416a6fae7c..4cee496d71 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -723,8 +723,7 @@ int hvf_vcpu_exec(CPUState *cpu) =20 hvf_store_events(cpu, ins_len, idtvec_info); rip =3D rreg(cpu->hvf_fd, HV_X86_RIP); - RFLAGS(env) =3D rreg(cpu->hvf_fd, HV_X86_RFLAGS); - env->eflags =3D RFLAGS(env); + env->eflags =3D rreg(cpu->hvf_fd, HV_X86_RFLAGS); =20 qemu_mutex_lock_iothread(); =20 @@ -736,7 +735,7 @@ int hvf_vcpu_exec(CPUState *cpu) case EXIT_REASON_HLT: { macvm_set_rip(cpu, rip + ins_len); if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && - (EFLAGS(env) & IF_MASK)) + (env->eflags & IF_MASK)) && !(cpu->interrupt_request & CPU_INTERRUPT_NMI) && !(idtvec_info & VMCS_IDT_VEC_VALID)) { cpu->halted =3D 1; diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c index 3afcedc7fc..7ebb5b45bd 100644 --- a/target/i386/hvf/x86.c +++ b/target/i386/hvf/x86.c @@ -131,7 +131,7 @@ bool x86_is_v8086(struct CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; - return x86_is_protected(cpu) && (RFLAGS(env) & RFLAGS_VM); + return x86_is_protected(cpu) && (env->eflags & RFLAGS_VM); } =20 bool x86_is_long_mode(struct CPUState *cpu) diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 411e4b6599..e309b8f203 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -62,44 +62,6 @@ typedef enum x86_rflags { RFLAGS_ID =3D (1L << 21), } x86_rflags; =20 -/* rflags register */ -typedef struct x86_reg_flags { - union { - struct { - uint64_t rflags; - }; - struct { - uint32_t eflags; - uint32_t hi32_unused1; - }; - struct { - uint32_t cf:1; - uint32_t unused1:1; - uint32_t pf:1; - uint32_t unused2:1; - uint32_t af:1; - uint32_t unused3:1; - uint32_t zf:1; - uint32_t sf:1; - uint32_t tf:1; - uint32_t ief:1; - uint32_t df:1; - uint32_t of:1; - uint32_t iopl:2; - uint32_t nt:1; - uint32_t unused4:1; - uint32_t rf:1; - uint32_t vm:1; - uint32_t ac:1; - uint32_t vif:1; - uint32_t vip:1; - uint32_t id:1; - uint32_t unused5:10; - uint32_t hi32_unused2; - }; - }; -} __attribute__ ((__packed__)) x86_reg_flags; - typedef enum x86_reg_cr0 { CR0_PE =3D (1L << 0), CR0_MP =3D (1L << 1), @@ -294,15 +256,11 @@ typedef struct lazy_flags { /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { struct x86_register regs[16]; - struct x86_reg_flags rflags; struct lazy_flags lflags; uint8_t mmio_buf[4096]; }; =20 /* useful register access macros */ -#define RFLAGS(cpu) (cpu->hvf_emul->rflags.rflags) -#define EFLAGS(cpu) (cpu->hvf_emul->rflags.eflags) - #define RRX(cpu, reg) (cpu->hvf_emul->regs[reg].rrx) #define RAX(cpu) RRX(cpu, R_EAX) #define RCX(cpu) RRX(cpu, R_ECX) diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 0efd9f9928..04fac64e72 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -459,7 +459,7 @@ static inline void string_increment_reg(struct CPUX86St= ate *env, int reg, struct x86_decode *decode) { target_ulong val =3D read_reg(env, reg, decode->addressing_size); - if (env->hvf_emul->rflags.df) { + if (env->eflags & DF_MASK) { val -=3D decode->operand_size; } else { val +=3D decode->operand_size; @@ -1432,7 +1432,7 @@ void load_regs(struct CPUState *cpu) RRX(env, i) =3D rreg(cpu->hvf_fd, HV_X86_RAX + i); } =20 - RFLAGS(env) =3D rreg(cpu->hvf_fd, HV_X86_RFLAGS); + env->eflags =3D rreg(cpu->hvf_fd, HV_X86_RFLAGS); rflags_to_lflags(env); env->eip =3D rreg(cpu->hvf_fd, HV_X86_RIP); } @@ -1456,7 +1456,7 @@ void store_regs(struct CPUState *cpu) } =20 lflags_to_rflags(env); - wreg(cpu->hvf_fd, HV_X86_RFLAGS, RFLAGS(env)); + wreg(cpu->hvf_fd, HV_X86_RFLAGS, env->eflags); macvm_set_rip(cpu, env->eip); } =20 diff --git a/target/i386/hvf/x86_flags.c b/target/i386/hvf/x86_flags.c index ee6d33f861..1152cd7234 100644 --- a/target/i386/hvf/x86_flags.c +++ b/target/i386/hvf/x86_flags.c @@ -295,21 +295,21 @@ void set_SF(CPUX86State *env, bool val) =20 void lflags_to_rflags(CPUX86State *env) { - env->hvf_emul->rflags.cf =3D get_CF(env); - env->hvf_emul->rflags.pf =3D get_PF(env); - env->hvf_emul->rflags.af =3D get_AF(env); - env->hvf_emul->rflags.zf =3D get_ZF(env); - env->hvf_emul->rflags.sf =3D get_SF(env); - env->hvf_emul->rflags.of =3D get_OF(env); + env->eflags |=3D get_CF(env) ? CC_C : 0; + env->eflags |=3D get_PF(env) ? CC_P : 0; + env->eflags |=3D get_AF(env) ? CC_A : 0; + env->eflags |=3D get_ZF(env) ? CC_Z : 0; + env->eflags |=3D get_SF(env) ? CC_S : 0; + env->eflags |=3D get_OF(env) ? CC_O : 0; } =20 void rflags_to_lflags(CPUX86State *env) { env->hvf_emul->lflags.auxbits =3D env->hvf_emul->lflags.result =3D 0; - set_OF(env, env->hvf_emul->rflags.of); - set_SF(env, env->hvf_emul->rflags.sf); - set_ZF(env, env->hvf_emul->rflags.zf); - set_AF(env, env->hvf_emul->rflags.af); - set_PF(env, env->hvf_emul->rflags.pf); - set_CF(env, env->hvf_emul->rflags.cf); + set_OF(env, env->eflags & CC_O); + set_SF(env, env->eflags & CC_S); + set_ZF(env, env->eflags & CC_Z); + set_AF(env, env->eflags & CC_A); + set_PF(env, env->eflags & CC_P); + set_CF(env, env->eflags & CC_C); } diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c index 834baec3ea..6ea8508946 100644 --- a/target/i386/hvf/x86_task.c +++ b/target/i386/hvf/x86_task.c @@ -39,7 +39,7 @@ static void save_state_to_tss32(CPUState *cpu, struct x86= _tss_segment32 *tss) =20 /* CR3 and ldt selector are not saved intentionally */ tss->eip =3D (uint32_t)env->eip; - tss->eflags =3D EFLAGS(env); + tss->eflags =3D (uint32_t)env->eflags; tss->eax =3D EAX(env); tss->ecx =3D ECX(env); tss->edx =3D EDX(env); @@ -65,7 +65,7 @@ static void load_state_from_tss32(CPUState *cpu, struct x= 86_tss_segment32 *tss) wvmcs(cpu->hvf_fd, VMCS_GUEST_CR3, tss->cr3); =20 env->eip =3D tss->eip; - EFLAGS(env) =3D tss->eflags | 2; + env->eflags =3D tss->eflags | 2; =20 /* General purpose registers */ RAX(env) =3D tss->eax; @@ -158,7 +158,7 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_= selector tss_sel, int rea } =20 if (reason =3D=3D TSR_IRET) - EFLAGS(env) &=3D ~RFLAGS_NT; + env->eflags &=3D ~RFLAGS_NT; =20 if (reason !=3D TSR_CALL && reason !=3D TSR_IDT_GATE) old_tss_sel.sel =3D 0xffff; diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index edefe5319a..5cbcb32ab6 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -412,7 +412,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state) =20 if (!(env->hflags & HF_INHIBIT_IRQ_MASK) && (cpu_state->interrupt_request & CPU_INTERRUPT_HARD) && - (EFLAGS(env) & IF_MASK) && !(info & VMCS_INTR_VALID)) { + (env->eflags & IF_MASK) && !(info & VMCS_INTR_VALID)) { int line =3D cpu_get_pic_interrupt(&x86cpu->env); cpu_state->interrupt_request &=3D ~CPU_INTERRUPT_HARD; if (line >=3D 0) { @@ -432,7 +432,7 @@ int hvf_process_events(CPUState *cpu_state) X86CPU *cpu =3D X86_CPU(cpu_state); CPUX86State *env =3D &cpu->env; =20 - EFLAGS(env) =3D rreg(cpu_state->hvf_fd, HV_X86_RFLAGS); + env->eflags =3D rreg(cpu_state->hvf_fd, HV_X86_RFLAGS); =20 if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) { hvf_cpu_synchronize_state(cpu_state); @@ -444,7 +444,7 @@ int hvf_process_events(CPUState *cpu_state) apic_poll_irq(cpu->apic_state); } if (((cpu_state->interrupt_request & CPU_INTERRUPT_HARD) && - (EFLAGS(env) & IF_MASK)) || + (env->eflags & IF_MASK)) || (cpu_state->interrupt_request & CPU_INTERRUPT_NMI)) { cpu_state->halted =3D 0; } --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591909374; cv=none; d=zohomail.com; s=zohoarc; b=Z8cBu0Jreh3MrEr6WHhVn5oFX06f2/wwgGnW+Zqcif/Q7nDG7F/tcYdpvMkzjkhpXeodedkN97VJzxdaGTcCRPUhSGeDW1g0Yz0nkR5oPY7qOYtxtKPghSbwGLIJ5FMl1v4yhD4D5IGigQBmBLRlS+0BtB9KXWvwfyTXOX5V0Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909374; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UMnr7zXWEWTvgAmjZlP3tjzkRRR2WfEvyUCiG7b0XSE=; b=lmR9SrVKWics2nai8FnjAJ0zi+EhshGaDY5VhxkQ4h8GkxDpHAeF0olpZNg9unKJh/bszp1UmQStD6COQtnI/Ja9enK2GVvqfO8I6DYsez1cidBpFDXkXnsWaklSoQ78hb0tgoC6rCc9yFx3McjKLQ8qMCcBLocg184ihjEqrSc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591909374144811.292916049542; Thu, 11 Jun 2020 14:02:54 -0700 (PDT) Received: from localhost ([::1]:49674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjULc-0006ca-9b for importer@patchew.org; Thu, 11 Jun 2020 17:02:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAK-0001jV-AO for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56276 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAI-0001P8-62 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-8SVmjhpvNceigRB55tpB7g-1; Thu, 11 Jun 2020 15:47:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ED9C845F29; Thu, 11 Jun 2020 19:47:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63EE10013D7; Thu, 11 Jun 2020 19:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904825; 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=UMnr7zXWEWTvgAmjZlP3tjzkRRR2WfEvyUCiG7b0XSE=; b=VTsoW1o7DGFSf1JU82O5DULgvWtUExSCuBc1kStl2LNdagDMqNZ2wcW4N7sqIwC2Cmb/Zs 6EV4+Qq8JYnPjHoEEq32ZiJLqYHGKl1ztQNNVHcjBv9AZ4NC9aLSYtjTlgAO4QNz4KuKVF n4uikH4ASKPOzYMXl52wZ2mnfNcAFFI= X-MC-Unique: 8SVmjhpvNceigRB55tpB7g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 094/115] i386: hvf: Drop copy of RFLAGS defines Date: Thu, 11 Jun 2020 15:44:28 -0400 Message-Id: <20200611194449.31468-95-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov Use the ones provided in target/i386/cpu.h instead. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-10-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/x86.c | 2 +- target/i386/hvf/x86.h | 20 -------------------- target/i386/hvf/x86_decode.c | 16 +++++++--------- target/i386/hvf/x86_task.c | 2 +- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c index 7ebb5b45bd..fdb11c8db9 100644 --- a/target/i386/hvf/x86.c +++ b/target/i386/hvf/x86.c @@ -131,7 +131,7 @@ bool x86_is_v8086(struct CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; - return x86_is_protected(cpu) && (env->eflags & RFLAGS_VM); + return x86_is_protected(cpu) && (env->eflags & VM_MASK); } =20 bool x86_is_long_mode(struct CPUState *cpu) diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index e309b8f203..f0d03faff9 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -42,26 +42,6 @@ typedef struct x86_register { }; } __attribute__ ((__packed__)) x86_register; =20 -typedef enum x86_rflags { - RFLAGS_CF =3D (1L << 0), - RFLAGS_PF =3D (1L << 2), - RFLAGS_AF =3D (1L << 4), - RFLAGS_ZF =3D (1L << 6), - RFLAGS_SF =3D (1L << 7), - RFLAGS_TF =3D (1L << 8), - RFLAGS_IF =3D (1L << 9), - RFLAGS_DF =3D (1L << 10), - RFLAGS_OF =3D (1L << 11), - RFLAGS_IOPL =3D (3L << 12), - RFLAGS_NT =3D (1L << 14), - RFLAGS_RF =3D (1L << 16), - RFLAGS_VM =3D (1L << 17), - RFLAGS_AC =3D (1L << 18), - RFLAGS_VIF =3D (1L << 19), - RFLAGS_VIP =3D (1L << 20), - RFLAGS_ID =3D (1L << 21), -} x86_rflags; - typedef enum x86_reg_cr0 { CR0_PE =3D (1L << 0), CR0_MP =3D (1L << 1), diff --git a/target/i386/hvf/x86_decode.c b/target/i386/hvf/x86_decode.c index d881542181..34c5e3006c 100644 --- a/target/i386/hvf/x86_decode.c +++ b/target/i386/hvf/x86_decode.c @@ -697,15 +697,13 @@ static void decode_db_4(CPUX86State *env, struct x86_= decode *decode) =20 =20 #define RFLAGS_MASK_NONE 0 -#define RFLAGS_MASK_OSZAPC (RFLAGS_OF | RFLAGS_SF | RFLAGS_ZF | RFLAGS_AF= | \ - RFLAGS_PF | RFLAGS_CF) -#define RFLAGS_MASK_LAHF (RFLAGS_SF | RFLAGS_ZF | RFLAGS_AF | RFLAGS_PF= | \ - RFLAGS_CF) -#define RFLAGS_MASK_CF (RFLAGS_CF) -#define RFLAGS_MASK_IF (RFLAGS_IF) -#define RFLAGS_MASK_TF (RFLAGS_TF) -#define RFLAGS_MASK_DF (RFLAGS_DF) -#define RFLAGS_MASK_ZF (RFLAGS_ZF) +#define RFLAGS_MASK_OSZAPC (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C) +#define RFLAGS_MASK_LAHF (CC_S | CC_Z | CC_A | CC_P | CC_C) +#define RFLAGS_MASK_CF (CC_C) +#define RFLAGS_MASK_IF (IF_MASK) +#define RFLAGS_MASK_TF (TF_MASK) +#define RFLAGS_MASK_DF (DF_MASK) +#define RFLAGS_MASK_ZF (CC_Z) =20 struct decode_tbl _1op_inst[] =3D { {0x0, X86_DECODE_CMD_ADD, 1, true, decode_modrm_rm, decode_modrm_reg, = NULL, diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c index 6ea8508946..6f04478b3a 100644 --- a/target/i386/hvf/x86_task.c +++ b/target/i386/hvf/x86_task.c @@ -158,7 +158,7 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_= selector tss_sel, int rea } =20 if (reason =3D=3D TSR_IRET) - env->eflags &=3D ~RFLAGS_NT; + env->eflags &=3D ~NT_MASK; =20 if (reason !=3D TSR_CALL && reason !=3D TSR_IDT_GATE) old_tss_sel.sel =3D 0xffff; --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907577; cv=none; d=zohomail.com; s=zohoarc; b=EePN5PRgbm5ClpBDL0mrf4F3Xal+vrRua5a3TVHOvmtj+cmyjd+zYwNvNiq0WDPyb1EwDQ5KWNUWxS7hntMAiZPbDStkI1UBZF0qjZhyezqF8ONL8vGOItzV3N9LJN+jSIHZWxU0JeWuFujqcA53DL12v/YdVogav+elj48Abvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g+uHjjnAp5c/+6ufY1U7RXcDnUhIgzyjschgUlhs8fQ=; b=ALtPVa7qTu1Z03E6Hgp9jEhzQUCdr/8jJgvV5xCdcd3Wep1hc0/y+bL+2Yc0rMeVMBgaup1xq8TSIkMbG0ZwE9XyC9SboYyrnL4DVJEUBxX9Fp6Yg3qylXEjd6V5AJCJOzgIhC9jfRdfxVjzV1Asz7aVEd5wGTy8o2hc/1mNmC8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907577684884.4102071029222; Thu, 11 Jun 2020 13:32:57 -0700 (PDT) Received: from localhost ([::1]:36274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTse-0007ym-Cz for importer@patchew.org; Thu, 11 Jun 2020 16:32:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAK-0001k4-Gx for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58966 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAI-0001PD-GL for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-Us5AppWfPEOowKH2jjDaVg-1; Thu, 11 Jun 2020 15:47:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD93584638F; Thu, 11 Jun 2020 19:47:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6056A10013D0; Thu, 11 Jun 2020 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904825; 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=g+uHjjnAp5c/+6ufY1U7RXcDnUhIgzyjschgUlhs8fQ=; b=Cc6y1+lO1ijn3qI1zkwIp5N2v+XVv/vUpI8C3GjlPfc8C6u8aOu4NcsFNMJVShRXe9FCZD +wK4BInnTxlkDdHlF//wQWjVl/ivb8HNfDBhCmQeDuSqZRayoM+EqnWI2C5+XEEIC6fYDq UFEb4kNDz1B/KrNbwDf3ikS1q4xjvY0= X-MC-Unique: Us5AppWfPEOowKH2jjDaVg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 095/115] i386: hvf: Drop regs in HVFX86EmulatorState Date: Thu, 11 Jun 2020 15:44:29 -0400 Message-Id: <20200611194449.31468-96-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov HVFX86EmulatorState carries it's own copy of x86 registers. It can be dropped in favor of regs in generic CPUX86State. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-11-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/x86.h | 13 +++++++------ target/i386/hvf/x86_emu.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index f0d03faff9..6048b5cc74 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -235,13 +235,14 @@ typedef struct lazy_flags { =20 /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { - struct x86_register regs[16]; struct lazy_flags lflags; uint8_t mmio_buf[4096]; }; =20 /* useful register access macros */ -#define RRX(cpu, reg) (cpu->hvf_emul->regs[reg].rrx) +#define x86_reg(cpu, reg) ((x86_register *) &cpu->regs[reg]) + +#define RRX(cpu, reg) (x86_reg(cpu, reg)->rrx) #define RAX(cpu) RRX(cpu, R_EAX) #define RCX(cpu) RRX(cpu, R_ECX) #define RDX(cpu) RRX(cpu, R_EDX) @@ -259,7 +260,7 @@ struct HVFX86EmulatorState { #define R14(cpu) RRX(cpu, R_R14) #define R15(cpu) RRX(cpu, R_R15) =20 -#define ERX(cpu, reg) (cpu->hvf_emul->regs[reg].erx) +#define ERX(cpu, reg) (x86_reg(cpu, reg)->erx) #define EAX(cpu) ERX(cpu, R_EAX) #define ECX(cpu) ERX(cpu, R_ECX) #define EDX(cpu) ERX(cpu, R_EDX) @@ -269,7 +270,7 @@ struct HVFX86EmulatorState { #define ESI(cpu) ERX(cpu, R_ESI) #define EDI(cpu) ERX(cpu, R_EDI) =20 -#define RX(cpu, reg) (cpu->hvf_emul->regs[reg].rx) +#define RX(cpu, reg) (x86_reg(cpu, reg)->rx) #define AX(cpu) RX(cpu, R_EAX) #define CX(cpu) RX(cpu, R_ECX) #define DX(cpu) RX(cpu, R_EDX) @@ -279,13 +280,13 @@ struct HVFX86EmulatorState { #define SI(cpu) RX(cpu, R_ESI) #define DI(cpu) RX(cpu, R_EDI) =20 -#define RL(cpu, reg) (cpu->hvf_emul->regs[reg].lx) +#define RL(cpu, reg) (x86_reg(cpu, reg)->lx) #define AL(cpu) RL(cpu, R_EAX) #define CL(cpu) RL(cpu, R_ECX) #define DL(cpu) RL(cpu, R_EDX) #define BL(cpu) RL(cpu, R_EBX) =20 -#define RH(cpu, reg) (cpu->hvf_emul->regs[reg].hx) +#define RH(cpu, reg) (x86_reg(cpu, reg)->hx) #define AH(cpu) RH(cpu, R_EAX) #define CH(cpu) RH(cpu, R_ECX) #define DH(cpu) RH(cpu, R_EDX) diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 04fac64e72..1ad2c30e16 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -95,13 +95,13 @@ target_ulong read_reg(CPUX86State *env, int reg, int si= ze) { switch (size) { case 1: - return env->hvf_emul->regs[reg].lx; + return x86_reg(env, reg)->lx; case 2: - return env->hvf_emul->regs[reg].rx; + return x86_reg(env, reg)->rx; case 4: - return env->hvf_emul->regs[reg].erx; + return x86_reg(env, reg)->erx; case 8: - return env->hvf_emul->regs[reg].rrx; + return x86_reg(env, reg)->rrx; default: abort(); } @@ -112,16 +112,16 @@ void write_reg(CPUX86State *env, int reg, target_ulon= g val, int size) { switch (size) { case 1: - env->hvf_emul->regs[reg].lx =3D val; + x86_reg(env, reg)->lx =3D val; break; case 2: - env->hvf_emul->regs[reg].rx =3D val; + x86_reg(env, reg)->rx =3D val; break; case 4: - env->hvf_emul->regs[reg].rrx =3D (uint32_t)val; + x86_reg(env, reg)->rrx =3D (uint32_t)val; break; case 8: - env->hvf_emul->regs[reg].rrx =3D val; + x86_reg(env, reg)->rrx =3D val; break; default: abort(); @@ -173,7 +173,7 @@ void write_val_to_reg(target_ulong reg_ptr, target_ulon= g val, int size) =20 static bool is_host_reg(struct CPUX86State *env, target_ulong ptr) { - return (ptr - (target_ulong)&env->hvf_emul->regs[0]) < sizeof(env->hvf= _emul->regs); + return (ptr - (target_ulong)&env->regs[0]) < sizeof(env->regs); } =20 void write_val_ext(struct CPUX86State *env, target_ulong ptr, target_ulong= val, int size) --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591909538; cv=none; d=zohomail.com; s=zohoarc; b=QlyPywBtZENBm3y9mlAnmED6LZenjhusj4PGQxdUin/WD2pbY1lcTVZ4yYZ9WtvblljjqcrQWqeJ8Z2CLKAQzJXVBLgdSRJNX7tDSvR4GDsvg0AdXhYrXTiqiotPb2kgXqfhIfyflOjT6htIcJb4hdFAWPoW5vKvyd9Byi9pins= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909538; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AQIWOhTCDVHiTyMJn0+EqEwqVEfH0zb1TnfAOMSKdac=; b=Ps+TkbTrrmMV994FiSgx+2t2nAh7awWLswFYzedqm8yp13meiEQU+xweb9ZknSyhBmNxg5kw2CbN/tsrm6rtfN8nwBcGurYIlTOsO0ADNqnrQ6ZZ+MIaXiaSPmARGZJpWCjqN4yIB9vIlbZtVesUWLOMw/k4HsEyWvoavHJ9fzY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591909538940408.0393356937666; Thu, 11 Jun 2020 14:05:38 -0700 (PDT) Received: from localhost ([::1]:56672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUOG-00019P-Sl for importer@patchew.org; Thu, 11 Jun 2020 17:05:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAP-0001tQ-7c for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48572 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAM-0001Pv-N4 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-FRmbtqxCNsaCilv7E3QbrA-1; Thu, 11 Jun 2020 15:47:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 921B8801503; Thu, 11 Jun 2020 19:47:03 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A54E10013D0; Thu, 11 Jun 2020 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904829; 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=AQIWOhTCDVHiTyMJn0+EqEwqVEfH0zb1TnfAOMSKdac=; b=MeKNZprrnoZfrSj5hpZI6/hQEgB8g0xhmg0g50Q0NaJnt8+01CIBjpo5Gf3pdWgQqyEBQc xFIV6IzPrA2JMA6r3j2/gJHZU9EP+yMP3cs5PjL5Hu4Tnldl7tQPwnPAieP6XDYnxYh9UR LhxCFYx0obKp5d0ir05N35vL0naFACU= X-MC-Unique: FRmbtqxCNsaCilv7E3QbrA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 096/115] i386: hvf: Move lazy_flags into CPUX86State Date: Thu, 11 Jun 2020 15:44:30 -0400 Message-Id: <20200611194449.31468-97-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Roman Bolshakov The lazy flags are still needed for instruction decoder. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-12-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/hvf.h | 7 +++++ target/i386/cpu.h | 2 ++ target/i386/hvf/x86.h | 6 ---- target/i386/hvf/x86_flags.c | 57 ++++++++++++++++++------------------- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index 2af32e505e..9e09144a64 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -21,10 +21,17 @@ #include #include #include "target/i386/cpu.h" +#include "exec/cpu-defs.h" + uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); extern bool hvf_allowed; #define hvf_enabled() (hvf_allowed) + +typedef struct hvf_lazy_flags { + target_ulong result; + target_ulong auxbits; +} hvf_lazy_flags; #else /* !CONFIG_HVF */ #define hvf_enabled() 0 #define hvf_get_supported_cpuid(func, idx, reg) 0 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c2b8bdcbde..86f4da1b66 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -20,6 +20,7 @@ #ifndef I386_CPU_H #define I386_CPU_H =20 +#include "sysemu/hvf.h" #include "sysemu/tcg.h" #include "cpu-qom.h" #include "hyperv-proto.h" @@ -1597,6 +1598,7 @@ typedef struct CPUX86State { struct kvm_nested_state *nested_state; #endif #if defined(CONFIG_HVF) + hvf_lazy_flags hvf_lflags; HVFX86EmulatorState *hvf_emul; #endif =20 diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 6048b5cc74..2363616c07 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -228,14 +228,8 @@ typedef struct x68_segment_selector { }; } __attribute__ ((__packed__)) x68_segment_selector; =20 -typedef struct lazy_flags { - target_ulong result; - target_ulong auxbits; -} lazy_flags; - /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { - struct lazy_flags lflags; uint8_t mmio_buf[4096]; }; =20 diff --git a/target/i386/hvf/x86_flags.c b/target/i386/hvf/x86_flags.c index 1152cd7234..5ca4f41f5c 100644 --- a/target/i386/hvf/x86_flags.c +++ b/target/i386/hvf/x86_flags.c @@ -63,7 +63,7 @@ #define SET_FLAGS_OSZAPC_SIZE(size, lf_carries, lf_result) { \ target_ulong temp =3D ((lf_carries) & (LF_MASK_AF)) | \ (((lf_carries) >> (size - 2)) << LF_BIT_PO); \ - env->hvf_emul->lflags.result =3D (target_ulong)(int##size##_t)(lf_resu= lt); \ + env->hvf_lflags.result =3D (target_ulong)(int##size##_t)(lf_result); \ if ((size) =3D=3D 32) { \ temp =3D ((lf_carries) & ~(LF_MASK_PDB | LF_MASK_SD)); \ } else if ((size) =3D=3D 16) { \ @@ -73,7 +73,7 @@ } else { \ VM_PANIC("unimplemented"); \ } \ - env->hvf_emul->lflags.auxbits =3D (target_ulong)(uint32_t)temp; \ + env->hvf_lflags.auxbits =3D (target_ulong)(uint32_t)temp; \ } =20 /* carries, result */ @@ -100,10 +100,10 @@ } else { \ VM_PANIC("unimplemented"); \ } \ - env->hvf_emul->lflags.result =3D (target_ulong)(int##size##_t)(lf_resu= lt); \ - target_ulong delta_c =3D (env->hvf_emul->lflags.auxbits ^ temp) & LF_M= ASK_CF; \ + env->hvf_lflags.result =3D (target_ulong)(int##size##_t)(lf_result); \ + target_ulong delta_c =3D (env->hvf_lflags.auxbits ^ temp) & LF_MASK_CF= ; \ delta_c ^=3D (delta_c >> 1); \ - env->hvf_emul->lflags.auxbits =3D (target_ulong)(uint32_t)(temp ^ delt= a_c); \ + env->hvf_lflags.auxbits =3D (target_ulong)(uint32_t)(temp ^ delta_c); \ } =20 /* carries, result */ @@ -117,9 +117,8 @@ void SET_FLAGS_OxxxxC(CPUX86State *env, uint32_t new_of, uint32_t new_cf) { uint32_t temp_po =3D new_of ^ new_cf; - env->hvf_emul->lflags.auxbits &=3D ~(LF_MASK_PO | LF_MASK_CF); - env->hvf_emul->lflags.auxbits |=3D (temp_po << LF_BIT_PO) | - (new_cf << LF_BIT_CF); + env->hvf_lflags.auxbits &=3D ~(LF_MASK_PO | LF_MASK_CF); + env->hvf_lflags.auxbits |=3D (temp_po << LF_BIT_PO) | (new_cf << LF_BI= T_CF); } =20 void SET_FLAGS_OSZAPC_SUB32(CPUX86State *env, uint32_t v1, uint32_t v2, @@ -215,27 +214,27 @@ void SET_FLAGS_OSZAPC_LOGIC8(CPUX86State *env, uint8_= t v1, uint8_t v2, =20 bool get_PF(CPUX86State *env) { - uint32_t temp =3D (255 & env->hvf_emul->lflags.result); - temp =3D temp ^ (255 & (env->hvf_emul->lflags.auxbits >> LF_BIT_PDB)); + uint32_t temp =3D (255 & env->hvf_lflags.result); + temp =3D temp ^ (255 & (env->hvf_lflags.auxbits >> LF_BIT_PDB)); temp =3D (temp ^ (temp >> 4)) & 0x0F; return (0x9669U >> temp) & 1; } =20 void set_PF(CPUX86State *env, bool val) { - uint32_t temp =3D (255 & env->hvf_emul->lflags.result) ^ (!val); - env->hvf_emul->lflags.auxbits &=3D ~(LF_MASK_PDB); - env->hvf_emul->lflags.auxbits |=3D (temp << LF_BIT_PDB); + uint32_t temp =3D (255 & env->hvf_lflags.result) ^ (!val); + env->hvf_lflags.auxbits &=3D ~(LF_MASK_PDB); + env->hvf_lflags.auxbits |=3D (temp << LF_BIT_PDB); } =20 bool get_OF(CPUX86State *env) { - return ((env->hvf_emul->lflags.auxbits + (1U << LF_BIT_PO)) >> LF_BIT_= CF) & 1; + return ((env->hvf_lflags.auxbits + (1U << LF_BIT_PO)) >> LF_BIT_CF) & = 1; } =20 bool get_CF(CPUX86State *env) { - return (env->hvf_emul->lflags.auxbits >> LF_BIT_CF) & 1; + return (env->hvf_lflags.auxbits >> LF_BIT_CF) & 1; } =20 void set_OF(CPUX86State *env, bool val) @@ -252,45 +251,45 @@ void set_CF(CPUX86State *env, bool val) =20 bool get_AF(CPUX86State *env) { - return (env->hvf_emul->lflags.auxbits >> LF_BIT_AF) & 1; + return (env->hvf_lflags.auxbits >> LF_BIT_AF) & 1; } =20 void set_AF(CPUX86State *env, bool val) { - env->hvf_emul->lflags.auxbits &=3D ~(LF_MASK_AF); - env->hvf_emul->lflags.auxbits |=3D val << LF_BIT_AF; + env->hvf_lflags.auxbits &=3D ~(LF_MASK_AF); + env->hvf_lflags.auxbits |=3D val << LF_BIT_AF; } =20 bool get_ZF(CPUX86State *env) { - return !env->hvf_emul->lflags.result; + return !env->hvf_lflags.result; } =20 void set_ZF(CPUX86State *env, bool val) { if (val) { - env->hvf_emul->lflags.auxbits ^=3D - (((env->hvf_emul->lflags.result >> LF_SIGN_BIT) & 1) << LF_BIT_SD= ); + env->hvf_lflags.auxbits ^=3D + (((env->hvf_lflags.result >> LF_SIGN_BIT) & 1) << LF_BIT_SD); /* merge the parity bits into the Parity Delta Byte */ - uint32_t temp_pdb =3D (255 & env->hvf_emul->lflags.result); - env->hvf_emul->lflags.auxbits ^=3D (temp_pdb << LF_BIT_PDB); + uint32_t temp_pdb =3D (255 & env->hvf_lflags.result); + env->hvf_lflags.auxbits ^=3D (temp_pdb << LF_BIT_PDB); /* now zero the .result value */ - env->hvf_emul->lflags.result =3D 0; + env->hvf_lflags.result =3D 0; } else { - env->hvf_emul->lflags.result |=3D (1 << 8); + env->hvf_lflags.result |=3D (1 << 8); } } =20 bool get_SF(CPUX86State *env) { - return ((env->hvf_emul->lflags.result >> LF_SIGN_BIT) ^ - (env->hvf_emul->lflags.auxbits >> LF_BIT_SD)) & 1; + return ((env->hvf_lflags.result >> LF_SIGN_BIT) ^ + (env->hvf_lflags.auxbits >> LF_BIT_SD)) & 1; } =20 void set_SF(CPUX86State *env, bool val) { bool temp_sf =3D get_SF(env); - env->hvf_emul->lflags.auxbits ^=3D (temp_sf ^ val) << LF_BIT_SD; + env->hvf_lflags.auxbits ^=3D (temp_sf ^ val) << LF_BIT_SD; } =20 void lflags_to_rflags(CPUX86State *env) @@ -305,7 +304,7 @@ void lflags_to_rflags(CPUX86State *env) =20 void rflags_to_lflags(CPUX86State *env) { - env->hvf_emul->lflags.auxbits =3D env->hvf_emul->lflags.result =3D 0; + env->hvf_lflags.auxbits =3D env->hvf_lflags.result =3D 0; set_OF(env, env->eflags & CC_O); set_SF(env, env->eflags & CC_S); set_ZF(env, env->eflags & CC_Z); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907693; cv=none; d=zohomail.com; s=zohoarc; b=RsAovZI4fzbgiObOLHexSbWXzzHzEWtp7yySwbNz6l9KSSQsLOmzQqNVbeSCiyrfYJXfW27+jtez0ZfpCwZuRn2HIBXSYuXeYBEFIVlu1rd7Gps+wujvVTOYZHKgYI0u6USOrno+aeRvpV2+15zuNgs2SMU0slbR/csNtNFE7/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907693; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lQvpU4B1D7EDUfj2jopXqI/yW1WBm3Uu35TpnhvGcVs=; b=EniS5MFxS05cinnCwtfD8HkvhPTIcCEUmedXja3JGQQoEfGvjg/XtooOIjLq0dMAy3wO/6S/q69/rYaSZLUnzXb9U8b96RuufnS9pzmXc3IqJyAhbPCWGNLslVrBH6WtFM0G9vq8uBp9HplFiGR/e239w+wbqVTrr2CZaN7ERrE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907693745250.71426637571767; Thu, 11 Jun 2020 13:34:53 -0700 (PDT) Received: from localhost ([::1]:44466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTuW-0003ke-Fn for importer@patchew.org; Thu, 11 Jun 2020 16:34:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAO-0001sT-Re for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:12 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:32584 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAM-0001Ps-Ev for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-pNj9KBEBNty97rlrVSzOjQ-1; Thu, 11 Jun 2020 15:47:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BDDE8015CE; Thu, 11 Jun 2020 19:47:04 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2FB110013D0; Thu, 11 Jun 2020 19:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904829; 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=lQvpU4B1D7EDUfj2jopXqI/yW1WBm3Uu35TpnhvGcVs=; b=ijrY6J/GEiN0NwjiXTBU4adP7Vfw4f4vYmNXrjSW5+bLSomjZlD52ehez/lEoaFAUHN1UX Zqenvlu/KRjTePq0C66uWM7MlXZS8JPxmDWt+iaHAWuSPnx8HQVOqtfD1gyCgzLusQ1CXN ZThta4VY9yo4TcDCMkJDNr5FG6igb8w= X-MC-Unique: pNj9KBEBNty97rlrVSzOjQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 097/115] i386: hvf: Move mmio_buf into CPUX86State Date: Thu, 11 Jun 2020 15:44:31 -0400 Message-Id: <20200611194449.31468-98-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov There's no similar field in CPUX86State, but it's needed for MMIO traps. Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-13-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/hvf/hvf.c | 5 +++++ target/i386/hvf/x86.h | 1 - target/i386/hvf/x86_emu.c | 12 ++++++------ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 86f4da1b66..da511a23b3 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1599,6 +1599,7 @@ typedef struct CPUX86State { #endif #if defined(CONFIG_HVF) hvf_lazy_flags hvf_lflags; + void *hvf_mmio_buf; HVFX86EmulatorState *hvf_emul; #endif =20 diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 4cee496d71..57696c46c7 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -533,7 +533,11 @@ void hvf_reset_vcpu(CPUState *cpu) { =20 void hvf_vcpu_destroy(CPUState *cpu) { + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + hv_return_t ret =3D hv_vcpu_destroy((hv_vcpuid_t)cpu->hvf_fd); + g_free(env->hvf_mmio_buf); assert_hvf_ok(ret); } =20 @@ -563,6 +567,7 @@ int hvf_init_vcpu(CPUState *cpu) init_decoder(); =20 hvf_state->hvf_caps =3D g_new0(struct hvf_vcpu_caps, 1); + env->hvf_mmio_buf =3D g_new(char, 4096); env->hvf_emul =3D g_new0(HVFX86EmulatorState, 1); =20 r =3D hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 2363616c07..483fcea762 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -230,7 +230,6 @@ typedef struct x68_segment_selector { =20 /* Definition of hvf_x86_state is here */ struct HVFX86EmulatorState { - uint8_t mmio_buf[4096]; }; =20 /* useful register access macros */ diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 1ad2c30e16..d3e289ed87 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -187,8 +187,8 @@ void write_val_ext(struct CPUX86State *env, target_ulon= g ptr, target_ulong val, =20 uint8_t *read_mmio(struct CPUX86State *env, target_ulong ptr, int bytes) { - vmx_read_mem(env_cpu(env), env->hvf_emul->mmio_buf, ptr, bytes); - return env->hvf_emul->mmio_buf; + vmx_read_mem(env_cpu(env), env->hvf_mmio_buf, ptr, bytes); + return env->hvf_mmio_buf; } =20 =20 @@ -489,9 +489,9 @@ static void exec_ins_single(struct CPUX86State *env, st= ruct x86_decode *decode) target_ulong addr =3D linear_addr_size(env_cpu(env), RDI(env), decode->addressing_size, R_ES); =20 - hvf_handle_io(env_cpu(env), DX(env), env->hvf_emul->mmio_buf, 0, + hvf_handle_io(env_cpu(env), DX(env), env->hvf_mmio_buf, 0, decode->operand_size, 1); - vmx_write_mem(env_cpu(env), addr, env->hvf_emul->mmio_buf, + vmx_write_mem(env_cpu(env), addr, env->hvf_mmio_buf, decode->operand_size); =20 string_increment_reg(env, R_EDI, decode); @@ -512,9 +512,9 @@ static void exec_outs_single(struct CPUX86State *env, s= truct x86_decode *decode) { target_ulong addr =3D decode_linear_addr(env, decode, RSI(env), R_DS); =20 - vmx_read_mem(env_cpu(env), env->hvf_emul->mmio_buf, addr, + vmx_read_mem(env_cpu(env), env->hvf_mmio_buf, addr, decode->operand_size); - hvf_handle_io(env_cpu(env), DX(env), env->hvf_emul->mmio_buf, 1, + hvf_handle_io(env_cpu(env), DX(env), env->hvf_mmio_buf, 1, decode->operand_size, 1); =20 string_increment_reg(env, R_ESI, decode); --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591907822; cv=none; d=zohomail.com; s=zohoarc; b=YWSEYgOPTFe2BNIfCe46v5rneF0iyQI986ZqxmoxnHFsUydDq4sVCj5LYLUYul/iojwlBzwrweC5JByJ0OX8d6y1gKxo5PXPeHIPZjT0kfdielW7x0n0gwe+A1dgdLqF0iQNudUcpCOffvIv2Ug2+IhiPyqKnxlkdAizBg1jdEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907822; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gQuqoF6ysfE+PJsNjiFp4bgJ5ewc0pmiCefhv+JlDGM=; b=Ul4iULDmKUGPgPu/LYUX11B5kq/mvHBHVUh+OdB4Kn/iRMbPBEWRW3iDjScHAIzixVglxzus3uTNCZPcUYJbhPIzabsVkFXmWWrj4eQt++X8GCb5t8ucrwjflwSXUP+5lhlyu652n4FjawJw1ICh/vj7NDqQg6f9IpqMYHFmkjE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907822214493.36636763753813; Thu, 11 Jun 2020 13:37:02 -0700 (PDT) Received: from localhost ([::1]:52130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTwb-000839-2Q for importer@patchew.org; Thu, 11 Jun 2020 16:37:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAP-0001uf-SF for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:13 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25832 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAN-0001QC-4c for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-281-hDbcjJ8aPoSTZN_bzTw1Kg-1; Thu, 11 Jun 2020 15:47:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D91E01005512; Thu, 11 Jun 2020 19:47:04 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C91410013D0; Thu, 11 Jun 2020 19:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904830; 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=gQuqoF6ysfE+PJsNjiFp4bgJ5ewc0pmiCefhv+JlDGM=; b=P8mzQ1MtqFAfyXXXUG6/9Key/ovmAnHSlmTPdvNKBN/JC2qrVu9EjPpuUWOUTK3VpEPbnc RVd3ki/I33vRrBl5QlJRyyB6OrZ4MdpdQ3IeUw91M0RPo/ZgtWEGs2l8uLaU7f8X0ydsf3 +KYpz0zHS4T57YH/xkmmUALWHs6QAGk= X-MC-Unique: hDbcjJ8aPoSTZN_bzTw1Kg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 098/115] i386: hvf: Drop HVFX86EmulatorState Date: Thu, 11 Jun 2020 15:44:32 -0400 Message-Id: <20200611194449.31468-99-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov Signed-off-by: Roman Bolshakov Message-Id: <20200528193758.51454-14-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini --- include/qemu/typedefs.h | 1 - target/i386/cpu.h | 1 - target/i386/hvf/hvf.c | 1 - target/i386/hvf/x86.h | 4 ---- 4 files changed, 7 deletions(-) diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index de68d51d52..ce4a78b687 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -51,7 +51,6 @@ typedef struct FWCfgIoState FWCfgIoState; typedef struct FWCfgMemState FWCfgMemState; typedef struct FWCfgState FWCfgState; typedef struct HostMemoryBackend HostMemoryBackend; -typedef struct HVFX86EmulatorState HVFX86EmulatorState; typedef struct I2CBus I2CBus; typedef struct I2SCodec I2SCodec; typedef struct IOMMUMemoryRegion IOMMUMemoryRegion; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index da511a23b3..c6f816c58d 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1600,7 +1600,6 @@ typedef struct CPUX86State { #if defined(CONFIG_HVF) hvf_lazy_flags hvf_lflags; void *hvf_mmio_buf; - HVFX86EmulatorState *hvf_emul; #endif =20 uint64_t mcg_cap; diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 57696c46c7..be016b951a 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -568,7 +568,6 @@ int hvf_init_vcpu(CPUState *cpu) =20 hvf_state->hvf_caps =3D g_new0(struct hvf_vcpu_caps, 1); env->hvf_mmio_buf =3D g_new(char, 4096); - env->hvf_emul =3D g_new0(HVFX86EmulatorState, 1); =20 r =3D hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); cpu->vcpu_dirty =3D 1; diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 483fcea762..bacade7b65 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -228,10 +228,6 @@ typedef struct x68_segment_selector { }; } __attribute__ ((__packed__)) x68_segment_selector; =20 -/* Definition of hvf_x86_state is here */ -struct HVFX86EmulatorState { -}; - /* useful register access macros */ #define x86_reg(cpu, reg) ((x86_register *) &cpu->regs[reg]) =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908598; cv=none; d=zohomail.com; s=zohoarc; b=ZNM3PbZ8NB2HktjaYLNerDr8vzpFc8NDwVLxbrRt40G/DSBDxZn6Myx76zoJM5oABCfmPvboKYK02M4+FhQs0l3Ma1MSo2WTrjy9nJO+X+aHWSg7eX2OFSa9OIX+lkNzc82IM13aDSpxix4lJf6fSKQEHIx0HNT6cdSgum3DV3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RGxMHpNptqdaZvQXjdJ5yya4fFnMAb6wlgy+j3rPvGE=; b=U4S4Q6h5nYHfUnrCX1mOt/jncNse95f3VivQZSsa/ox2laeAWf/7R9hHOvuFd2caU7qixuRpp3NsgT7dw6mEFrTBrAwK3sfcV9h9sKxqPkHp+NGVVDFr9+wkKBBhhoezS30/UBPNYTbqz2vNpLUC8qc8yDb3LufMPqo/5d0MCVg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908598072456.5511982554282; Thu, 11 Jun 2020 13:49:58 -0700 (PDT) Received: from localhost ([::1]:38514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU96-0005PT-SV for importer@patchew.org; Thu, 11 Jun 2020 16:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAh-0002Ge-E2 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53915 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAe-0001T3-Tw for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-13IiX5iuNbKySQWiz3ccUw-1; Thu, 11 Jun 2020 15:47:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A36361940920; Thu, 11 Jun 2020 19:47:05 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 165EE10013D0; Thu, 11 Jun 2020 19:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904844; 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=RGxMHpNptqdaZvQXjdJ5yya4fFnMAb6wlgy+j3rPvGE=; b=iJ08dnP0yLVeHMS5Sy9QSifoCmBhgwdqMcLPwSIt3AT1CXFlwH7OyLPj5CVUKO/mg6HwN3 OzirjZ9BlQMtXrO3Ih76GQS7r2X2fVPdvXjeesjfKfkOU6Twvx8K0LSNF2xQThOuL9lmIJ kL3riZNmvyf1nkfbTO0aR3Y/DlgOpV8= X-MC-Unique: 13IiX5iuNbKySQWiz3ccUw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 099/115] xen: fix build without pci passthrough Date: Thu, 11 Jun 2020 15:44:33 -0400 Message-Id: <20200611194449.31468-100-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Anthony PERARD Xen PCI passthrough support may not be available and thus the global variable "has_igd_gfx_passthru" might be compiled out. Common code should not access it in that case. Unfortunately, we can't use CONFIG_XEN_PCI_PASSTHROUGH directly in xen-common.c so this patch instead move access to the has_igd_gfx_passthru variable via function and those functions are also implemented as stubs. The stubs will be used when QEMU is built without passthrough support. Now, when one will want to enable igd-passthru via the -machine property, they will get an error message if QEMU is built without passthrough support. Fixes: 46472d82322d0 ('xen: convert "-machine igd-passthru" to an accelerat= or property') Reported-by: Roger Pau Monn=C3=A9 Signed-off-by: Anthony PERARD Message-Id: <20200603160442.3151170-1-anthony.perard@citrix.com> Signed-off-by: Paolo Bonzini --- accel/xen/xen-all.c | 4 ++-- hw/Makefile.objs | 2 +- hw/i386/pc_piix.c | 2 +- hw/xen/Makefile.objs | 3 ++- hw/xen/xen_pt.c | 12 +++++++++++- hw/xen/xen_pt.h | 6 ++++-- hw/xen/xen_pt_stub.c | 22 ++++++++++++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 hw/xen/xen_pt_stub.c diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index f3edc65ec9..0c24d4b191 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -137,12 +137,12 @@ static void xen_change_state_handler(void *opaque, in= t running, =20 static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp) { - return has_igd_gfx_passthru; + return xen_igd_gfx_pt_enabled(); } =20 static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp) { - has_igd_gfx_passthru =3D value; + xen_igd_gfx_pt_set(value, errp); } =20 static void xen_setup_post(MachineState *ms, AccelState *accel) diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 660e2b4373..4cbe5e4e57 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -35,7 +35,7 @@ devices-dirs-y +=3D usb/ devices-dirs-$(CONFIG_VFIO) +=3D vfio/ devices-dirs-y +=3D virtio/ devices-dirs-y +=3D watchdog/ -devices-dirs-y +=3D xen/ +devices-dirs-$(CONFIG_XEN) +=3D xen/ devices-dirs-$(CONFIG_MEM_DEVICE) +=3D mem/ devices-dirs-$(CONFIG_NUBUS) +=3D nubus/ devices-dirs-y +=3D semihosting/ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index eea964e72b..054d3aa9f7 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -377,7 +377,7 @@ static void pc_init_isa(MachineState *machine) #ifdef CONFIG_XEN static void pc_xen_hvm_init_pci(MachineState *machine) { - const char *pci_type =3D has_igd_gfx_passthru ? + const char *pci_type =3D xen_igd_gfx_pt_enabled() ? TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_D= EVICE; =20 pc_init1(machine, diff --git a/hw/xen/Makefile.objs b/hw/xen/Makefile.objs index 340b2c5096..3fc715e595 100644 --- a/hw/xen/Makefile.objs +++ b/hw/xen/Makefile.objs @@ -1,6 +1,7 @@ # xen backend driver support -common-obj-$(CONFIG_XEN) +=3D xen-legacy-backend.o xen_devconfig.o xen_pvd= ev.o xen-bus.o xen-bus-helper.o xen-backend.o +common-obj-y +=3D xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-bus= .o xen-bus-helper.o xen-backend.o =20 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) +=3D xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) +=3D xen_pt.o xen_pt_config_init.o xen_p= t_graphics.o xen_pt_msi.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) +=3D xen_pt_load_rom.o +obj-$(call $(lnot, $(CONFIG_XEN_PCI_PASSTHROUGH))) +=3D xen_pt_stub.o diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 81d5ad8da7..ab84443d5e 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -65,7 +65,17 @@ #include "qemu/range.h" #include "exec/address-spaces.h" =20 -bool has_igd_gfx_passthru; +static bool has_igd_gfx_passthru; + +bool xen_igd_gfx_pt_enabled(void) +{ + return has_igd_gfx_passthru; +} + +void xen_igd_gfx_pt_set(bool value, Error **errp) +{ + has_igd_gfx_passthru =3D value; +} =20 #define XEN_PT_NR_IRQS (256) static uint8_t xen_pt_mapped_machine_irq[XEN_PT_NR_IRQS] =3D {0}; diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h index 179775db7b..6e9cec95f3 100644 --- a/hw/xen/xen_pt.h +++ b/hw/xen/xen_pt.h @@ -5,6 +5,9 @@ #include "hw/pci/pci.h" #include "xen-host-pci-device.h" =20 +bool xen_igd_gfx_pt_enabled(void); +void xen_igd_gfx_pt_set(bool value, Error **errp); + void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3); =20 #define XEN_PT_ERR(d, _f, _a...) xen_pt_log(d, "%s: Error: "_f, __func__, = ##_a) @@ -322,10 +325,9 @@ extern void *pci_assign_dev_load_option_rom(PCIDevice = *dev, unsigned int domain, unsigned int bus, unsigned int= slot, unsigned int function); -extern bool has_igd_gfx_passthru; static inline bool is_igd_vga_passthrough(XenHostPCIDevice *dev) { - return (has_igd_gfx_passthru + return (xen_igd_gfx_pt_enabled() && ((dev->class_code >> 0x8) =3D=3D PCI_CLASS_DISPLAY_VGA)); } int xen_pt_register_vga_regions(XenHostPCIDevice *dev); diff --git a/hw/xen/xen_pt_stub.c b/hw/xen/xen_pt_stub.c new file mode 100644 index 0000000000..2d8cac8d54 --- /dev/null +++ b/hw/xen/xen_pt_stub.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 Citrix Systems UK Ltd. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/xen/xen_pt.h" +#include "qapi/error.h" + +bool xen_igd_gfx_pt_enabled(void) +{ + return false; +} + +void xen_igd_gfx_pt_set(bool value, Error **errp) +{ + if (value) { + error_setg(errp, "Xen PCI passthrough support not built in"); + } +} --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908121; cv=none; d=zohomail.com; s=zohoarc; b=RyiZPrdUgxVZl+iDT1z35MvFcT0F0WL55PgjrPJ20saa6Z6NeYGJ64/O7+DyEDm36J+/sUmtK22X2RQivQO0Me3VfPEk5oqXrP+eJ+D+EXFgyIjUZhkOgSkRBfF4IO+jDx1nok3R5bv6Qy2aWuWTskklCYVcLTGYjCxsBLhIEYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908121; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h8HdZFaM2mWIMMStldX3gYxAELTzDvL+kCBAAkvkGiU=; b=IHdWnorzKmRVN1ZFC3Uu94QgFUMUkjF3FiSCVkG5LM37mhpCqe7dMyyJuml/9f863QSjoW7QMQmXyvOnXHNuvgyFQYG0wTTT+46vqwyPqs2hKstvgUAnJVHLCSA0XQTZwTFPPdja6yJEdmfVlXGYWRDIE37kVLjFZ/98fErBNSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908121360276.73217447337254; Thu, 11 Jun 2020 13:42:01 -0700 (PDT) Received: from localhost ([::1]:41340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU1Q-0007qi-0g for importer@patchew.org; Thu, 11 Jun 2020 16:42:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAR-0001yB-Dc for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29240 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAO-0001QP-1e for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309---Fyvq-BPvCmIEh85Dr9TA-1; Thu, 11 Jun 2020 15:47:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 485F81940923; Thu, 11 Jun 2020 19:47:07 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56B8560CC0; Thu, 11 Jun 2020 19:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904831; 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=h8HdZFaM2mWIMMStldX3gYxAELTzDvL+kCBAAkvkGiU=; b=Paottn9J7o0cfOMeutD/jJwEE8gpENKlpbtQknjM6r8CtMgOH0KmadIfog4k5ObXeW6xCH 7qFAQafdiU+oyuZ8BwkrqSP3UqcbmJ7WzLwUVVag68vVpr5MPSigyEOe0M6viqb0fb7v5D HdgQi6ApZy2ExrTmOe6ilB4XBvFvhA0= X-MC-Unique: --Fyvq-BPvCmIEh85Dr9TA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 100/115] target/i386: sev: Remove unused QSevGuestInfoClass Date: Thu, 11 Jun 2020 15:44:34 -0400 Message-Id: <20200611194449.31468-101-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson This structure is nothing but an empty wrapper around the parent class, which by QOM conventions means we don't need it at all. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-2-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 1 - target/i386/sev_i386.h | 5 ----- 2 files changed, 6 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 51cdbe5496..2312510cf2 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -287,7 +287,6 @@ static const TypeInfo qsev_guest_info =3D { .name =3D TYPE_QSEV_GUEST_INFO, .instance_size =3D sizeof(QSevGuestInfo), .instance_finalize =3D qsev_guest_finalize, - .class_size =3D sizeof(QSevGuestInfoClass), .class_init =3D qsev_guest_class_init, .instance_init =3D qsev_guest_init, .interfaces =3D (InterfaceInfo[]) { diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 8ada9d385d..4f193642ac 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -41,7 +41,6 @@ extern char *sev_get_launch_measurement(void); extern SevCapability *sev_get_capabilities(void); =20 typedef struct QSevGuestInfo QSevGuestInfo; -typedef struct QSevGuestInfoClass QSevGuestInfoClass; =20 /** * QSevGuestInfo: @@ -64,10 +63,6 @@ struct QSevGuestInfo { uint32_t reduced_phys_bits; }; =20 -struct QSevGuestInfoClass { - ObjectClass parent_class; -}; - struct SEVState { QSevGuestInfo *sev_info; uint8_t api_major; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907966; cv=none; d=zohomail.com; s=zohoarc; b=joIX15RfHz8zRlkkNSPWpVqtRAjwJCdN+ApAw9E5AYsEJGpzcQIFOJvgJjrbWCOJIGj4i9l1IKVSBQxZib/2FqNwEDyOttnPMCRks3koTxF5Ae0yz5ozHGF4+A8Z5lXbuS6W44cteLLJL+pI64rdel8ol2mccs1rWK1dogPgKlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907966; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=81izy4+9EMYGX4ur7U9oBg5fWRzOwFW3sWwfve6UJ8w=; b=dvNW0WSbK80+CnRHW93Cm6cOgrRRjWFpGuWDwp12umnFLSOYvSC+ZK/mTGaMBfe53Q9oy0TY0CLEZI7zga2u/0/tRIKrSHyJp0ud11RRyat/LIcv6LHSGW3GN0LGyDya0o6ox552l5pCRVd/xeqZpHLh7OW0+tKg9iqbPrcLM7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190796640525.566255278804306; Thu, 11 Jun 2020 13:39:26 -0700 (PDT) Received: from localhost ([::1]:33098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTyv-0003zk-4j for importer@patchew.org; Thu, 11 Jun 2020 16:39:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAQ-0001xG-Uu for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:43153 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAO-0001QN-02 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-S4DT20YwORSQibEJzFNBPA-1; Thu, 11 Jun 2020 15:47:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25DF3107ACF3; Thu, 11 Jun 2020 19:47:08 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7946460CC0; Thu, 11 Jun 2020 19:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904831; 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=81izy4+9EMYGX4ur7U9oBg5fWRzOwFW3sWwfve6UJ8w=; b=EEU6JdrTVQO+lC8cCjb8+9id3jDvyy4y4WZQyYnK6yZFpnjmxyPLGkX1EHDbAOrDLLmtC4 D5vZEpDiAUMpZxqWHyICkpZj3+UB90BUMeOcdCZVb0/4ZDm1MY3MkIoTNe89DTjMYW624L 3S7UlxlNou1ztMyytIpsYH/fZOyIjKA= X-MC-Unique: S4DT20YwORSQibEJzFNBPA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 101/115] target/i386: sev: Move local structure definitions into .c file Date: Thu, 11 Jun 2020 15:44:35 -0400 Message-Id: <20200611194449.31468-102-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson Neither QSevGuestInfo nor SEVState (not to be confused with SevState) is used anywhere outside target/i386/sev.c, so they might as well live in there rather than in a (somewhat) exposed header. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-3-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 44 ++++++++++++++++++++++++++++++++++++++++++ target/i386/sev_i386.h | 44 ------------------------------------------ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 2312510cf2..53def5f41a 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -29,6 +29,50 @@ #include "trace.h" #include "migration/blocker.h" =20 +#define TYPE_QSEV_GUEST_INFO "sev-guest" +#define QSEV_GUEST_INFO(obj) \ + OBJECT_CHECK(QSevGuestInfo, (obj), TYPE_QSEV_GUEST_INFO) + +typedef struct QSevGuestInfo QSevGuestInfo; + +/** + * QSevGuestInfo: + * + * The QSevGuestInfo object is used for creating a SEV guest. + * + * # $QEMU \ + * -object sev-guest,id=3Dsev0 \ + * -machine ...,memory-encryption=3Dsev0 + */ +struct QSevGuestInfo { + Object parent_obj; + + char *sev_device; + uint32_t policy; + uint32_t handle; + char *dh_cert_file; + char *session_file; + uint32_t cbitpos; + uint32_t reduced_phys_bits; +}; + +struct SEVState { + QSevGuestInfo *sev_info; + uint8_t api_major; + uint8_t api_minor; + uint8_t build_id; + uint32_t policy; + uint64_t me_mask; + uint32_t cbitpos; + uint32_t reduced_phys_bits; + uint32_t handle; + int sev_fd; + SevState state; + gchar *measurement; +}; + +typedef struct SEVState SEVState; + #define DEFAULT_GUEST_POLICY 0x1 /* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev" =20 diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 4f193642ac..8eb7de1bef 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -28,10 +28,6 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 =20 -#define TYPE_QSEV_GUEST_INFO "sev-guest" -#define QSEV_GUEST_INFO(obj) \ - OBJECT_CHECK(QSevGuestInfo, (obj), TYPE_QSEV_GUEST_INFO) - extern bool sev_enabled(void); extern uint64_t sev_get_me_mask(void); extern SevInfo *sev_get_info(void); @@ -40,44 +36,4 @@ extern uint32_t sev_get_reduced_phys_bits(void); extern char *sev_get_launch_measurement(void); extern SevCapability *sev_get_capabilities(void); =20 -typedef struct QSevGuestInfo QSevGuestInfo; - -/** - * QSevGuestInfo: - * - * The QSevGuestInfo object is used for creating a SEV guest. - * - * # $QEMU \ - * -object sev-guest,id=3Dsev0 \ - * -machine ...,memory-encryption=3Dsev0 - */ -struct QSevGuestInfo { - Object parent_obj; - - char *sev_device; - uint32_t policy; - uint32_t handle; - char *dh_cert_file; - char *session_file; - uint32_t cbitpos; - uint32_t reduced_phys_bits; -}; - -struct SEVState { - QSevGuestInfo *sev_info; - uint8_t api_major; - uint8_t api_minor; - uint8_t build_id; - uint32_t policy; - uint64_t me_mask; - uint32_t cbitpos; - uint32_t reduced_phys_bits; - uint32_t handle; - int sev_fd; - SevState state; - gchar *measurement; -}; - -typedef struct SEVState SEVState; - #endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591909621; cv=none; d=zohomail.com; s=zohoarc; b=l9J6SdILSv02cARjLNnCguecv6y/O5c9Y5qS/4y/86pOql7CymIdCSKun/scSSx3uxjABaDvCCXWMQnKejESx0GOAI/lSlvRFO0KXarGMWjMDVzr5/y7VH6X7G6iQEZaR/kNHEFRJGao5CRyWw0XOxmKEHwxMOs8YIZ4P+XVnmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909621; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rH/ZRONMPh9IjqYbOFigbB9B9pKvj83UfzobVXF1za8=; b=YTFbqSKwzXYvo8VkTSSPCT5sTQdae5n4H4KkwFbimlrlxyOvjwNoorjiSCpGow4B60Y+sXNyhCs/IorVNCJgDZ/BaJ/Bf5c+1fmVY6TdxBhLq/+kEQVj3ppZNitMgSEZpfWRVqqpvda/7HBcfLCmdR3SO1L6a5d5Fbal78QqMh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591909621115602.9527869587967; Thu, 11 Jun 2020 14:07:01 -0700 (PDT) Received: from localhost ([::1]:33346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUPb-0003JH-Td for importer@patchew.org; Thu, 11 Jun 2020 17:06:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAS-0001zY-9f for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28089 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAO-0001Qc-Tu for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-svuejcEfP52MH-OHaU3Phg-1; Thu, 11 Jun 2020 15:47:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 039B79116F; Thu, 11 Jun 2020 19:47:09 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56EFA60CC0; Thu, 11 Jun 2020 19:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904832; 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=rH/ZRONMPh9IjqYbOFigbB9B9pKvj83UfzobVXF1za8=; b=Copq0zFuR+nDNvjuMKHMEHaq5JwcAZYPKipR4KsVBFlNrz+boRsiXrogKEvdja01Tj5aG5 +rotoUjTzcJPSKz/kXTiPLKhn6atI6Ta4RVNkQhpNRNUPg5mNpa+yIX88B96bZ6Md8KnYC 0Ev3sFaeidukB99xbCQLsprWVkN9bng= X-MC-Unique: svuejcEfP52MH-OHaU3Phg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 102/115] target/i386: sev: Rename QSevGuestInfo Date: Thu, 11 Jun 2020 15:44:36 -0400 Message-Id: <20200611194449.31468-103-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson At the moment this is a purely passive object which is just a container for information used elsewhere, hence the name. I'm going to change that though, so as a preliminary rename it to SevGuestState. That name risks confusion with both SEVState and SevState, but I'll be working on that in following patches. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-4-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 87 ++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 53def5f41a..b6ed719fb5 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -29,22 +29,23 @@ #include "trace.h" #include "migration/blocker.h" =20 -#define TYPE_QSEV_GUEST_INFO "sev-guest" -#define QSEV_GUEST_INFO(obj) \ - OBJECT_CHECK(QSevGuestInfo, (obj), TYPE_QSEV_GUEST_INFO) +#define TYPE_SEV_GUEST "sev-guest" +#define SEV_GUEST(obj) \ + OBJECT_CHECK(SevGuestState, (obj), TYPE_SEV_GUEST) =20 -typedef struct QSevGuestInfo QSevGuestInfo; +typedef struct SevGuestState SevGuestState; =20 /** - * QSevGuestInfo: + * SevGuestState: * - * The QSevGuestInfo object is used for creating a SEV guest. + * The SevGuestState object is used for creating and managing a SEV + * guest. * * # $QEMU \ * -object sev-guest,id=3Dsev0 \ * -machine ...,memory-encryption=3Dsev0 */ -struct QSevGuestInfo { +struct SevGuestState { Object parent_obj; =20 char *sev_device; @@ -57,7 +58,7 @@ struct QSevGuestInfo { }; =20 struct SEVState { - QSevGuestInfo *sev_info; + SevGuestState *sev_info; uint8_t api_major; uint8_t api_minor; uint8_t build_id; @@ -235,82 +236,82 @@ static struct RAMBlockNotifier sev_ram_notifier =3D { }; =20 static void -qsev_guest_finalize(Object *obj) +sev_guest_finalize(Object *obj) { } =20 static char * -qsev_guest_get_session_file(Object *obj, Error **errp) +sev_guest_get_session_file(Object *obj, Error **errp) { - QSevGuestInfo *s =3D QSEV_GUEST_INFO(obj); + SevGuestState *s =3D SEV_GUEST(obj); =20 return s->session_file ? g_strdup(s->session_file) : NULL; } =20 static void -qsev_guest_set_session_file(Object *obj, const char *value, Error **errp) +sev_guest_set_session_file(Object *obj, const char *value, Error **errp) { - QSevGuestInfo *s =3D QSEV_GUEST_INFO(obj); + SevGuestState *s =3D SEV_GUEST(obj); =20 s->session_file =3D g_strdup(value); } =20 static char * -qsev_guest_get_dh_cert_file(Object *obj, Error **errp) +sev_guest_get_dh_cert_file(Object *obj, Error **errp) { - QSevGuestInfo *s =3D QSEV_GUEST_INFO(obj); + SevGuestState *s =3D SEV_GUEST(obj); =20 return g_strdup(s->dh_cert_file); } =20 static void -qsev_guest_set_dh_cert_file(Object *obj, const char *value, Error **errp) +sev_guest_set_dh_cert_file(Object *obj, const char *value, Error **errp) { - QSevGuestInfo *s =3D QSEV_GUEST_INFO(obj); + SevGuestState *s =3D SEV_GUEST(obj); =20 s->dh_cert_file =3D g_strdup(value); } =20 static char * -qsev_guest_get_sev_device(Object *obj, Error **errp) +sev_guest_get_sev_device(Object *obj, Error **errp) { - QSevGuestInfo *sev =3D QSEV_GUEST_INFO(obj); + SevGuestState *sev =3D SEV_GUEST(obj); =20 return g_strdup(sev->sev_device); } =20 static void -qsev_guest_set_sev_device(Object *obj, const char *value, Error **errp) +sev_guest_set_sev_device(Object *obj, const char *value, Error **errp) { - QSevGuestInfo *sev =3D QSEV_GUEST_INFO(obj); + SevGuestState *sev =3D SEV_GUEST(obj); =20 sev->sev_device =3D g_strdup(value); } =20 static void -qsev_guest_class_init(ObjectClass *oc, void *data) +sev_guest_class_init(ObjectClass *oc, void *data) { object_class_property_add_str(oc, "sev-device", - qsev_guest_get_sev_device, - qsev_guest_set_sev_device); + sev_guest_get_sev_device, + sev_guest_set_sev_device); object_class_property_set_description(oc, "sev-device", "SEV device to use"); object_class_property_add_str(oc, "dh-cert-file", - qsev_guest_get_dh_cert_file, - qsev_guest_set_dh_cert_file); + sev_guest_get_dh_cert_file, + sev_guest_set_dh_cert_file); object_class_property_set_description(oc, "dh-cert-file", "guest owners DH certificate (encoded with base64)"); object_class_property_add_str(oc, "session-file", - qsev_guest_get_session_file, - qsev_guest_set_session_file); + sev_guest_get_session_file, + sev_guest_set_session_file); object_class_property_set_description(oc, "session-file", "guest owners session parameters (encoded with base64)"); } =20 static void -qsev_guest_init(Object *obj) +sev_guest_instance_init(Object *obj) { - QSevGuestInfo *sev =3D QSEV_GUEST_INFO(obj); + SevGuestState *sev =3D SEV_GUEST(obj); =20 sev->sev_device =3D g_strdup(DEFAULT_SEV_DEVICE); sev->policy =3D DEFAULT_GUEST_POLICY; @@ -326,32 +327,32 @@ qsev_guest_init(Object *obj) } =20 /* sev guest info */ -static const TypeInfo qsev_guest_info =3D { +static const TypeInfo sev_guest_info =3D { .parent =3D TYPE_OBJECT, - .name =3D TYPE_QSEV_GUEST_INFO, - .instance_size =3D sizeof(QSevGuestInfo), - .instance_finalize =3D qsev_guest_finalize, - .class_init =3D qsev_guest_class_init, - .instance_init =3D qsev_guest_init, + .name =3D TYPE_SEV_GUEST, + .instance_size =3D sizeof(SevGuestState), + .instance_finalize =3D sev_guest_finalize, + .class_init =3D sev_guest_class_init, + .instance_init =3D sev_guest_instance_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } } }; =20 -static QSevGuestInfo * +static SevGuestState * lookup_sev_guest_info(const char *id) { Object *obj; - QSevGuestInfo *info; + SevGuestState *info; =20 obj =3D object_resolve_path_component(object_get_objects_root(), id); if (!obj) { return NULL; } =20 - info =3D (QSevGuestInfo *) - object_dynamic_cast(obj, TYPE_QSEV_GUEST_INFO); + info =3D (SevGuestState *) + object_dynamic_cast(obj, TYPE_SEV_GUEST); if (!info) { return NULL; } @@ -510,7 +511,7 @@ sev_launch_start(SEVState *s) gsize sz; int ret =3D 1; int fw_error, rc; - QSevGuestInfo *sev =3D s->sev_info; + SevGuestState *sev =3D s->sev_info; struct kvm_sev_launch_start *start; guchar *session =3D NULL, *dh_cert =3D NULL; =20 @@ -696,7 +697,7 @@ sev_guest_init(const char *id) s->sev_info =3D lookup_sev_guest_info(id); if (!s->sev_info) { error_report("%s: '%s' is not a valid '%s' object", - __func__, id, TYPE_QSEV_GUEST_INFO); + __func__, id, TYPE_SEV_GUEST); goto err; } =20 @@ -786,7 +787,7 @@ sev_encrypt_data(void *handle, uint8_t *ptr, uint64_t l= en) static void sev_register_types(void) { - type_register_static(&qsev_guest_info); + type_register_static(&sev_guest_info); } =20 type_init(sev_register_types); --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591909775; cv=none; d=zohomail.com; s=zohoarc; b=TtOmIhMCmeI3Y23jiXoo9KHCiqjiA4+7fcQ92avhow1JxA4sM6rv0Uu2G2WHtUE8vJy+FZyWfiA4m1IGFJwsOVSoIfBPQTPb3SSFouMYBRV/5lCzezbzZi23b/33ptPmfC/6ZeMAkGeF91BYigxlZpg6WUFS5Sc7utulMTMsVM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909775; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7LYwErl+pjehaD/v6IjJrKIbuSevbP1X5aYkjdO9wfo=; b=kdLR7vDtS0SJaYplZc1EnOgQAgTY/7SzPNSWjn7beTqW9IEn3REoX5PLjWJzWNFKBwkXv02TG2tu24kM+oSeenCmayTDRWWm+6bASAKATm/zu9f/rhNenv3PnGItdY1wZNOH1sdCnE6sKZTnVcQ9wtFC/smyUtp6aQEVXv7DdnI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591909775872771.725958072671; Thu, 11 Jun 2020 14:09:35 -0700 (PDT) Received: from localhost ([::1]:40882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUS6-0007LJ-Mc for importer@patchew.org; Thu, 11 Jun 2020 17:09:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAU-00024J-T0 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:18 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48322 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAS-0001RO-0h for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-PfAqDDAwOz2odoyl91YKWg-1; Thu, 11 Jun 2020 15:47:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D522A194092A; Thu, 11 Jun 2020 19:47:09 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34C7260CC0; Thu, 11 Jun 2020 19:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904835; 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=7LYwErl+pjehaD/v6IjJrKIbuSevbP1X5aYkjdO9wfo=; b=AGgHacX0Hirla6oUR7AAPSmTCOpSRe7kAl/1gjytOeac1VtFNQj7p2M9liKbA8iiTeGQT6 GBq9dAPLPeZvzyLLoUce4Q4WcP4oBoBMcn0Q402hy08Ih97TV+mgS53JY/mp/KInSCD+JW mWUuaC78ZPSnX65wC/louz1hDOV3R/4= X-MC-Unique: PfAqDDAwOz2odoyl91YKWg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 103/115] target/i386: sev: Embed SEVState in SevGuestState Date: Thu, 11 Jun 2020 15:44:37 -0400 Message-Id: <20200611194449.31468-104-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson Currently SevGuestState contains only configuration information. For runtime state another non-QOM struct SEVState is allocated separately. Simplify things by instead embedding the SEVState structure in SevGuestState. Signed-off-by: David Gibson Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200604064219.436242-5-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 54 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index b6ed719fb5..b4ab9720d6 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -35,6 +35,22 @@ =20 typedef struct SevGuestState SevGuestState; =20 +struct SEVState { + uint8_t api_major; + uint8_t api_minor; + uint8_t build_id; + uint32_t policy; + uint64_t me_mask; + uint32_t cbitpos; + uint32_t reduced_phys_bits; + uint32_t handle; + int sev_fd; + SevState state; + gchar *measurement; +}; + +typedef struct SEVState SEVState; + /** * SevGuestState: * @@ -48,6 +64,7 @@ typedef struct SevGuestState SevGuestState; struct SevGuestState { Object parent_obj; =20 + /* configuration parameters */ char *sev_device; uint32_t policy; uint32_t handle; @@ -55,25 +72,11 @@ struct SevGuestState { char *session_file; uint32_t cbitpos; uint32_t reduced_phys_bits; -}; =20 -struct SEVState { - SevGuestState *sev_info; - uint8_t api_major; - uint8_t api_minor; - uint8_t build_id; - uint32_t policy; - uint64_t me_mask; - uint32_t cbitpos; - uint32_t reduced_phys_bits; - uint32_t handle; - int sev_fd; - SevState state; - gchar *measurement; + /* runtime state */ + SEVState state; }; =20 -typedef struct SEVState SEVState; - #define DEFAULT_GUEST_POLICY 0x1 /* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev" =20 @@ -506,12 +509,12 @@ sev_read_file_base64(const char *filename, guchar **d= ata, gsize *len) } =20 static int -sev_launch_start(SEVState *s) +sev_launch_start(SevGuestState *sev) { + SEVState *s =3D &sev->state; gsize sz; int ret =3D 1; int fw_error, rc; - SevGuestState *sev =3D s->sev_info; struct kvm_sev_launch_start *start; guchar *session =3D NULL, *dh_cert =3D NULL; =20 @@ -686,6 +689,7 @@ sev_vm_state_change(void *opaque, int running, RunState= state) void * sev_guest_init(const char *id) { + SevGuestState *sev; SEVState *s; char *devname; int ret, fw_error; @@ -693,27 +697,27 @@ sev_guest_init(const char *id) uint32_t host_cbitpos; struct sev_user_data_status status =3D {}; =20 - sev_state =3D s =3D g_new0(SEVState, 1); - s->sev_info =3D lookup_sev_guest_info(id); - if (!s->sev_info) { + sev =3D lookup_sev_guest_info(id); + if (!sev) { error_report("%s: '%s' is not a valid '%s' object", __func__, id, TYPE_SEV_GUEST); goto err; } =20 + sev_state =3D s =3D &sev->state; s->state =3D SEV_STATE_UNINIT; =20 host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); host_cbitpos =3D ebx & 0x3f; =20 - s->cbitpos =3D object_property_get_int(OBJECT(s->sev_info), "cbitpos",= NULL); + s->cbitpos =3D object_property_get_int(OBJECT(sev), "cbitpos", NULL); if (host_cbitpos !=3D s->cbitpos) { error_report("%s: cbitpos check failed, host '%d' requested '%d'", __func__, host_cbitpos, s->cbitpos); goto err; } =20 - s->reduced_phys_bits =3D object_property_get_int(OBJECT(s->sev_info), + s->reduced_phys_bits =3D object_property_get_int(OBJECT(sev), "reduced-phys-bits", NULL); if (s->reduced_phys_bits < 1) { error_report("%s: reduced_phys_bits check failed, it should be >= =3D1," @@ -723,7 +727,7 @@ sev_guest_init(const char *id) =20 s->me_mask =3D ~(1UL << s->cbitpos); =20 - devname =3D object_property_get_str(OBJECT(s->sev_info), "sev-device",= NULL); + devname =3D object_property_get_str(OBJECT(sev), "sev-device", NULL); s->sev_fd =3D open(devname, O_RDWR); if (s->sev_fd < 0) { error_report("%s: Failed to open %s '%s'", __func__, @@ -754,7 +758,7 @@ sev_guest_init(const char *id) goto err; } =20 - ret =3D sev_launch_start(s); + ret =3D sev_launch_start(sev); if (ret) { error_report("%s: failed to create encryption context", __func__); goto err; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591907957; cv=none; d=zohomail.com; s=zohoarc; b=fjWvBwDilnJgOC/EI13xRcW6PO3L4blfHEHbonAYRdQ6pO5c6pI8YLrt5YZBgWtaAX5mFomO9i+0puRGuFiMpDQp7c1Bg7qKi1JwxNgUc3CKQ+EEw6312ezLMgputt2Wfpb3Hc7G3Mdm17kvo2d29fu7M9GxFWr2KHgjnZbFDQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591907957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bi/K7EoFa5VhHkEuUhS0oQiIWt1B3Y4tZYBeByfoKKE=; b=eS3r4iL/q85PLprA+D/S+LLxtmE4jBtsaIqDKsosjYAJYWzgdInfLm1Q87Wn4EiphxWsVI8nmFKrNyg+VH5eSXnkD1UdvWQVap3HL4TJPl+8NkYuFbyp6ajzgmz0fZCXD1E6D24whSscIzQX/0syuG4cQ5C3+C2Ol8SgbV2YsDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591907957345389.91614014411766; Thu, 11 Jun 2020 13:39:17 -0700 (PDT) Received: from localhost ([::1]:60496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjTyl-0003cn-W3 for importer@patchew.org; Thu, 11 Jun 2020 16:39:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAT-00021o-El for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:17 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:25833 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAQ-0001R0-IN for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-IGkmISY1MTqg0QKNJHaYRQ-1; Thu, 11 Jun 2020 15:47:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B38BD801503; Thu, 11 Jun 2020 19:47:10 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1278760CC0; Thu, 11 Jun 2020 19:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904833; 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=Bi/K7EoFa5VhHkEuUhS0oQiIWt1B3Y4tZYBeByfoKKE=; b=TPdn/vmFkEdM7KIcClZXBgg1COfuN4DbR8Bg55AIzMa/gumKj+04/CQoS7ybiMALbIqTLL 5RYAsnKlkmZhbhq8kwe0P5D0A7qhyi+K7ugGASy/hAFndWoPZkolLN8oKPXyQF2wEJ38qR dqaTqzB4uor33qv6dTHsdM6agOkGjas= X-MC-Unique: IGkmISY1MTqg0QKNJHaYRQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 104/115] target/i386: sev: Partial cleanup to sev_state global Date: Thu, 11 Jun 2020 15:44:38 -0400 Message-Id: <20200611194449.31468-105-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson The SEV code uses a pretty ugly global to access its internal state. Now that SEVState is embedded in SevGuestState, we can avoid accessing it via the global in some cases. In the remaining cases use a new global referencing the containing SevGuestState which will simplify some future transformations. Signed-off-by: David Gibson Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200604064219.436242-6-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 92 ++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index b4ab9720d6..9e8ab7b056 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -80,7 +80,7 @@ struct SevGuestState { #define DEFAULT_GUEST_POLICY 0x1 /* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev" =20 -static SEVState *sev_state; +static SevGuestState *sev_guest; static Error *sev_mig_blocker; =20 static const char *const sev_fw_errlist[] =3D { @@ -159,21 +159,21 @@ fw_error_to_str(int code) } =20 static bool -sev_check_state(SevState state) +sev_check_state(const SevGuestState *sev, SevState state) { - assert(sev_state); - return sev_state->state =3D=3D state ? true : false; + assert(sev); + return sev->state.state =3D=3D state ? true : false; } =20 static void -sev_set_guest_state(SevState new_state) +sev_set_guest_state(SevGuestState *sev, SevState new_state) { assert(new_state < SEV_STATE__MAX); - assert(sev_state); + assert(sev); =20 - trace_kvm_sev_change_state(SevState_str(sev_state->state), + trace_kvm_sev_change_state(SevState_str(sev->state.state), SevState_str(new_state)); - sev_state->state =3D new_state; + sev->state.state =3D new_state; } =20 static void @@ -366,25 +366,25 @@ lookup_sev_guest_info(const char *id) bool sev_enabled(void) { - return sev_state ? true : false; + return !!sev_guest; } =20 uint64_t sev_get_me_mask(void) { - return sev_state ? sev_state->me_mask : ~0; + return sev_guest ? sev_guest->state.me_mask : ~0; } =20 uint32_t sev_get_cbit_position(void) { - return sev_state ? sev_state->cbitpos : 0; + return sev_guest ? sev_guest->state.cbitpos : 0; } =20 uint32_t sev_get_reduced_phys_bits(void) { - return sev_state ? sev_state->reduced_phys_bits : 0; + return sev_guest ? sev_guest->state.reduced_phys_bits : 0; } =20 SevInfo * @@ -393,15 +393,15 @@ sev_get_info(void) SevInfo *info; =20 info =3D g_new0(SevInfo, 1); - info->enabled =3D sev_state ? true : false; + info->enabled =3D sev_enabled(); =20 if (info->enabled) { - info->api_major =3D sev_state->api_major; - info->api_minor =3D sev_state->api_minor; - info->build_id =3D sev_state->build_id; - info->policy =3D sev_state->policy; - info->state =3D sev_state->state; - info->handle =3D sev_state->handle; + info->api_major =3D sev_guest->state.api_major; + info->api_minor =3D sev_guest->state.api_minor; + info->build_id =3D sev_guest->state.build_id; + info->policy =3D sev_guest->state.policy; + info->state =3D sev_guest->state.state; + info->handle =3D sev_guest->state.handle; } =20 return info; @@ -550,7 +550,7 @@ sev_launch_start(SevGuestState *sev) =20 object_property_set_int(OBJECT(sev), start->handle, "handle", &error_abort); - sev_set_guest_state(SEV_STATE_LAUNCH_UPDATE); + sev_set_guest_state(sev, SEV_STATE_LAUNCH_UPDATE); s->handle =3D start->handle; s->policy =3D start->policy; ret =3D 0; @@ -563,7 +563,7 @@ out: } =20 static int -sev_launch_update_data(uint8_t *addr, uint64_t len) +sev_launch_update_data(SevGuestState *sev, uint8_t *addr, uint64_t len) { int ret, fw_error; struct kvm_sev_launch_update_data update; @@ -575,7 +575,7 @@ sev_launch_update_data(uint8_t *addr, uint64_t len) update.uaddr =3D (__u64)(unsigned long)addr; update.len =3D len; trace_kvm_sev_launch_update_data(addr, len); - ret =3D sev_ioctl(sev_state->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA, + ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA, &update, &fw_error); if (ret) { error_report("%s: LAUNCH_UPDATE ret=3D%d fw_error=3D%d '%s'", @@ -588,19 +588,20 @@ sev_launch_update_data(uint8_t *addr, uint64_t len) static void sev_launch_get_measure(Notifier *notifier, void *unused) { + SevGuestState *sev =3D sev_guest; int ret, error; guchar *data; - SEVState *s =3D sev_state; + SEVState *s =3D &sev->state; struct kvm_sev_launch_measure *measurement; =20 - if (!sev_check_state(SEV_STATE_LAUNCH_UPDATE)) { + if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) { return; } =20 measurement =3D g_new0(struct kvm_sev_launch_measure, 1); =20 /* query the measurement blob length */ - ret =3D sev_ioctl(sev_state->sev_fd, KVM_SEV_LAUNCH_MEASURE, + ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_MEASURE, measurement, &error); if (!measurement->len) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", @@ -612,7 +613,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement->uaddr =3D (unsigned long)data; =20 /* get the measurement blob */ - ret =3D sev_ioctl(sev_state->sev_fd, KVM_SEV_LAUNCH_MEASURE, + ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_MEASURE, measurement, &error); if (ret) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", @@ -620,7 +621,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) goto free_data; } =20 - sev_set_guest_state(SEV_STATE_LAUNCH_SECRET); + sev_set_guest_state(sev, SEV_STATE_LAUNCH_SECRET); =20 /* encode the measurement value and emit the event */ s->measurement =3D g_base64_encode(data, measurement->len); @@ -635,9 +636,9 @@ free_measurement: char * sev_get_launch_measurement(void) { - if (sev_state && - sev_state->state >=3D SEV_STATE_LAUNCH_SECRET) { - return g_strdup(sev_state->measurement); + if (sev_guest && + sev_guest->state.state >=3D SEV_STATE_LAUNCH_SECRET) { + return g_strdup(sev_guest->state.measurement); } =20 return NULL; @@ -648,20 +649,21 @@ static Notifier sev_machine_done_notify =3D { }; =20 static void -sev_launch_finish(SEVState *s) +sev_launch_finish(SevGuestState *sev) { + SEVState *s =3D &sev->state; int ret, error; Error *local_err =3D NULL; =20 trace_kvm_sev_launch_finish(); - ret =3D sev_ioctl(sev_state->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); + ret =3D sev_ioctl(s->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); if (ret) { error_report("%s: LAUNCH_FINISH ret=3D%d fw_error=3D%d '%s'", __func__, ret, error, fw_error_to_str(error)); exit(1); } =20 - sev_set_guest_state(SEV_STATE_RUNNING); + sev_set_guest_state(sev, SEV_STATE_RUNNING); =20 /* add migration blocker */ error_setg(&sev_mig_blocker, @@ -677,11 +679,11 @@ sev_launch_finish(SEVState *s) static void sev_vm_state_change(void *opaque, int running, RunState state) { - SEVState *s =3D opaque; + SevGuestState *sev =3D opaque; =20 if (running) { - if (!sev_check_state(SEV_STATE_RUNNING)) { - sev_launch_finish(s); + if (!sev_check_state(sev, SEV_STATE_RUNNING)) { + sev_launch_finish(sev); } } } @@ -704,7 +706,8 @@ sev_guest_init(const char *id) goto err; } =20 - sev_state =3D s =3D &sev->state; + sev_guest =3D sev; + s =3D &sev->state; s->state =3D SEV_STATE_UNINIT; =20 host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); @@ -766,23 +769,24 @@ sev_guest_init(const char *id) =20 ram_block_notifier_add(&sev_ram_notifier); qemu_add_machine_init_done_notifier(&sev_machine_done_notify); - qemu_add_vm_change_state_handler(sev_vm_state_change, s); + qemu_add_vm_change_state_handler(sev_vm_state_change, sev); =20 - return s; + return sev; err: - g_free(sev_state); - sev_state =3D NULL; + sev_guest =3D NULL; return NULL; } =20 int sev_encrypt_data(void *handle, uint8_t *ptr, uint64_t len) { - assert(handle); + SevGuestState *sev =3D handle; + + assert(sev); =20 /* if SEV is in update state then encrypt the data else do nothing */ - if (sev_check_state(SEV_STATE_LAUNCH_UPDATE)) { - return sev_launch_update_data(ptr, len); + if (sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) { + return sev_launch_update_data(sev, ptr, len); } =20 return 0; --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591909715; cv=none; d=zohomail.com; s=zohoarc; b=SONFXgfrd+xhGYJEvv9kj85pWSi1bUAWq7IxDGktGTx92EMaFR6r5N44XvTKJ7Q9Nj6WPa4G+stfadt5YZCgyH+yEq+NCIfcDvUu1gPFPXo+6ETeysuozChzomjuhrnhLZCWD9hJBWzgn2kECVvNGSH5S2RR5YnHCnKP9OA3QlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909715; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9/OUN2Gm+Qv34d8XgHbVohMxvKK4pJQF7AYNg438zXs=; b=go5UCwCxFOkF4EDzMFypH3xgb24nG9WBSwa1Xb57rPmLQrKpAKsFrVpJgO1hAVNyQNXeuYHY434T/cFXDLMMw0aLvPYRPeFlJtAnTNZO1U2xtgmPtEdPyRIJulQ59MmHaluFtD46Rm5nBqud971+4PdpXunw4Xb3DVy+/o8PQ2E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159190971585382.70614562515266; Thu, 11 Jun 2020 14:08:35 -0700 (PDT) Received: from localhost ([::1]:38116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUR8-0005jM-EX for importer@patchew.org; Thu, 11 Jun 2020 17:08:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAU-000236-5X for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:18 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58126 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAR-0001RD-FZ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-bOGQXV0CPkmpE-zG7cMWcg-1; Thu, 11 Jun 2020 15:47:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90F7D1940923; Thu, 11 Jun 2020 19:47:11 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4689610FD; Thu, 11 Jun 2020 19:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904834; 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=9/OUN2Gm+Qv34d8XgHbVohMxvKK4pJQF7AYNg438zXs=; b=LYBQZn5uTeD56T72r6WFjwFckk2e+0lRVGYETy8UMlugEPwoTpvx+nlPLeFHVtevTFEpfG ey1C4ROHTGHechUh0xrYkQGos11gNDNLnXq+vnGHQtAH6Z8LBToyJn6GnTOGBdqIEiZNgi +ZJtiEjuGaj+VW3xs1lgBNHeunM9GXM= X-MC-Unique: bOGQXV0CPkmpE-zG7cMWcg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 105/115] target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields Date: Thu, 11 Jun 2020 15:44:39 -0400 Message-Id: <20200611194449.31468-106-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson The SEVState structure has cbitpos and reduced_phys_bits fields which are simply copied from the SevGuestState structure and never changed. Now that SEVState is embedded in SevGuestState we can just access the original copy directly. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-7-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 9e8ab7b056..d25af37136 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -41,8 +41,6 @@ struct SEVState { uint8_t build_id; uint32_t policy; uint64_t me_mask; - uint32_t cbitpos; - uint32_t reduced_phys_bits; uint32_t handle; int sev_fd; SevState state; @@ -378,13 +376,13 @@ sev_get_me_mask(void) uint32_t sev_get_cbit_position(void) { - return sev_guest ? sev_guest->state.cbitpos : 0; + return sev_guest ? sev_guest->cbitpos : 0; } =20 uint32_t sev_get_reduced_phys_bits(void) { - return sev_guest ? sev_guest->state.reduced_phys_bits : 0; + return sev_guest ? sev_guest->reduced_phys_bits : 0; } =20 SevInfo * @@ -713,22 +711,19 @@ sev_guest_init(const char *id) host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); host_cbitpos =3D ebx & 0x3f; =20 - s->cbitpos =3D object_property_get_int(OBJECT(sev), "cbitpos", NULL); - if (host_cbitpos !=3D s->cbitpos) { + if (host_cbitpos !=3D sev->cbitpos) { error_report("%s: cbitpos check failed, host '%d' requested '%d'", - __func__, host_cbitpos, s->cbitpos); + __func__, host_cbitpos, sev->cbitpos); goto err; } =20 - s->reduced_phys_bits =3D object_property_get_int(OBJECT(sev), - "reduced-phys-bits", NULL); - if (s->reduced_phys_bits < 1) { + if (sev->reduced_phys_bits < 1) { error_report("%s: reduced_phys_bits check failed, it should be >= =3D1," - " requested '%d'", __func__, s->reduced_phys_bits); + " requested '%d'", __func__, sev->reduced_phys_bits); goto err; } =20 - s->me_mask =3D ~(1UL << s->cbitpos); + s->me_mask =3D ~(1UL << sev->cbitpos); =20 devname =3D object_property_get_str(OBJECT(sev), "sev-device", NULL); s->sev_fd =3D open(devname, O_RDWR); --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591910196; cv=none; d=zohomail.com; s=zohoarc; b=ELVjQAoci9TnjZB1U9h+YQnWcaBc/iQSbWazgMKBAi3aqI+5EH0/ORm7Q7X6HcGfwzZ3ESmWSx1UvUYgrTyF7IkSoJ2xn1nUG116CZVSp96sYuXAHmLyW5NKo9/5npxVmxNU7PsU5R3/Q1au7a2ZeiXKS0SA7gq/xP2R/3nRoXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591910196; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2xKDOACYyJpLQJRqYHzBMhYwWIAw/U81pYzegx6+Uwk=; b=PIrSAcsp2CAEgyYpEXP8j9Q48WTPaOVP3NvgP4xOzgi5YJwe8qoAz+E4AFZ2aP5KsirTAJci4ZqQfqaQQa1aDAtMJHy/VS4k2cFKavSr3I2KGVBIAGecybMLTuEGBWZW3hbOMJ0mDEmfMqK7JYXG+bBc4zPN8dZIcyJ8xCYngeQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591910196702914.0625725246458; Thu, 11 Jun 2020 14:16:36 -0700 (PDT) Received: from localhost ([::1]:53260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUYt-0007nw-Cc for importer@patchew.org; Thu, 11 Jun 2020 17:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTB8-0002tL-V3 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:58 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26263 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTB7-0001Xr-1O for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-Dk-Ks-o0OF6_-Xsi5lXFxQ-1; Thu, 11 Jun 2020 15:47:13 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54220107BEFC; Thu, 11 Jun 2020 19:47:12 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1F19610FD; Thu, 11 Jun 2020 19:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904876; 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=2xKDOACYyJpLQJRqYHzBMhYwWIAw/U81pYzegx6+Uwk=; b=PVUW4vVGkV0yxDuYAr0x7w13VgJANL34nKugrjZpHbQNgEip4ihXdkOx+Va0ScX/msnL2h PnH70RjNJG54Q6JmawStp6RvirgfS65u9+hfGQFsHxFkWaShKK+kav5V3Fih5OPpJbJPyg Q7dvL3AUlNGerZ0lMecuV2+8R0RCHnY= X-MC-Unique: Dk-Ks-o0OF6_-Xsi5lXFxQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 106/115] target/i386: sev: Remove redundant policy field Date: Thu, 11 Jun 2020 15:44:40 -0400 Message-Id: <20200611194449.31468-107-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: David Gibson SEVState::policy is set from the final value of the policy field in the parameter structure for the KVM_SEV_LAUNCH_START ioctl(). But, AFAICT that ioctl() won't ever change it from the original supplied value which comes from SevGuestState::policy. So, remove this field and just use SevGuestState::policy directly. Signed-off-by: David Gibson Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-8-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index d25af37136..4b261beaa7 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -39,7 +39,6 @@ struct SEVState { uint8_t api_major; uint8_t api_minor; uint8_t build_id; - uint32_t policy; uint64_t me_mask; uint32_t handle; int sev_fd; @@ -397,7 +396,7 @@ sev_get_info(void) info->api_major =3D sev_guest->state.api_major; info->api_minor =3D sev_guest->state.api_minor; info->build_id =3D sev_guest->state.build_id; - info->policy =3D sev_guest->state.policy; + info->policy =3D sev_guest->policy; info->state =3D sev_guest->state.state; info->handle =3D sev_guest->state.handle; } @@ -520,8 +519,7 @@ sev_launch_start(SevGuestState *sev) =20 start->handle =3D object_property_get_int(OBJECT(sev), "handle", &error_abort); - start->policy =3D object_property_get_int(OBJECT(sev), "policy", - &error_abort); + start->policy =3D sev->policy; if (sev->session_file) { if (sev_read_file_base64(sev->session_file, &session, &sz) < 0) { goto out; @@ -550,7 +548,6 @@ sev_launch_start(SevGuestState *sev) &error_abort); sev_set_guest_state(sev, SEV_STATE_LAUNCH_UPDATE); s->handle =3D start->handle; - s->policy =3D start->policy; ret =3D 0; =20 out: --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908291; cv=none; d=zohomail.com; s=zohoarc; b=HwMvhUZ0dY+hD8wR/FPgTfV/tNJPTQttYqvLPIVdIqjD1xqIelWz8nUf18WQoMfhd9rebTVf1o/xFGXl9FTkhKtCyIQ40TdW21CFrWHHpjpR6ObMtunEdcDPz2Ry9kfM64n0L8nyeQ33AU5EQo0NnPcBE3JyDtnXZdSrL2wlEnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908291; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZKJIvV9OiKDJs+uKZkXRizJk0uQGzPTTdysb8e5qLKM=; b=kQA6Jw3Wyr3x/sH+zGUCLpEOZtayeH7MI9u7qTLyVFyIqfeyw4KmxYrs3jEBaato9DOUWZBM4PYatrz1QKU81Ikr1FfTPZbadjg07ZEVuiR4JW8LIvrGVYi+GKIoz7VZJBWWHPDceE3KhYvAuRnFxyjgAzikM+4Q0WFgZTX1Hzs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908291936933.3456674869384; Thu, 11 Jun 2020 13:44:51 -0700 (PDT) Received: from localhost ([::1]:48680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU4A-0003XX-IX for importer@patchew.org; Thu, 11 Jun 2020 16:44:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAX-00027a-EE for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36047 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAT-0001Ra-0W for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-ySrPJyMiMseRkM8Yjq81Nw-1; Thu, 11 Jun 2020 15:47:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18AC9194092A; Thu, 11 Jun 2020 19:47:13 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8560060CC0; Thu, 11 Jun 2020 19:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904836; 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=ZKJIvV9OiKDJs+uKZkXRizJk0uQGzPTTdysb8e5qLKM=; b=Ps9ME2MryqwwxGa7/F5qG7XEU8uJ2JoNoi5ZRwpVIc1i2tFFCHYmP7l87FdURX5eRR0WuD ypTd4VMM3ItFxO5O58XKJE/R6Jece8UHoHa+md+MR19qJyBswb1KMJd+G9ZiV5P2iN2Oh8 tQkYCV/Oeo5vV+CMu8D4u8Ky43TyGGc= X-MC-Unique: ySrPJyMiMseRkM8Yjq81Nw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 107/115] target/i386: sev: Remove redundant handle field Date: Thu, 11 Jun 2020 15:44:41 -0400 Message-Id: <20200611194449.31468-108-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: David Gibson The user can explicitly specify a handle via the "handle" property wired to SevGuestState::handle. That gets passed to the KVM_SEV_LAUNCH_START ioctl() which may update it, the final value being copied back to both SevGuestState::handle and SEVState::handle. AFAICT, nothing will be looking SEVState::handle before it and SevGuestState::handle have been updated from the ioctl(). So, remove the field and just use SevGuestState::handle directly. Signed-off-by: David Gibson Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-9-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 4b261beaa7..24e2dea9b8 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -40,7 +40,6 @@ struct SEVState { uint8_t api_minor; uint8_t build_id; uint64_t me_mask; - uint32_t handle; int sev_fd; SevState state; gchar *measurement; @@ -64,13 +63,13 @@ struct SevGuestState { /* configuration parameters */ char *sev_device; uint32_t policy; - uint32_t handle; char *dh_cert_file; char *session_file; uint32_t cbitpos; uint32_t reduced_phys_bits; =20 /* runtime state */ + uint32_t handle; SEVState state; }; =20 @@ -398,7 +397,7 @@ sev_get_info(void) info->build_id =3D sev_guest->state.build_id; info->policy =3D sev_guest->policy; info->state =3D sev_guest->state.state; - info->handle =3D sev_guest->state.handle; + info->handle =3D sev_guest->handle; } =20 return info; @@ -517,8 +516,7 @@ sev_launch_start(SevGuestState *sev) =20 start =3D g_new0(struct kvm_sev_launch_start, 1); =20 - start->handle =3D object_property_get_int(OBJECT(sev), "handle", - &error_abort); + start->handle =3D sev->handle; start->policy =3D sev->policy; if (sev->session_file) { if (sev_read_file_base64(sev->session_file, &session, &sz) < 0) { @@ -544,10 +542,8 @@ sev_launch_start(SevGuestState *sev) goto out; } =20 - object_property_set_int(OBJECT(sev), start->handle, "handle", - &error_abort); sev_set_guest_state(sev, SEV_STATE_LAUNCH_UPDATE); - s->handle =3D start->handle; + sev->handle =3D start->handle; ret =3D 0; =20 out: --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591909900; cv=none; d=zohomail.com; s=zohoarc; b=X0v26foOHQ6x0KJdzjDqP7sd+tjJkvtMrRl06KhozUM34TOn3hRNjt/gD8BsFFxWRtupmUIcENWLXS8uyfR9J9WAGQVubCdrZT2lYSMT9YCkFT17joAAsXj1CqkZPK/SizJHTQg3MpXi97Shdolbpd8KyIa6rjeCjL/NXPeIRIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591909900; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b51M9KztetPMSGfaOOWNQjB7fE1LQXN0ycQf577nQoE=; b=STASQXLppT4kVFnrtQbLOnU4ghOkfrjJRgXQzqimwBKNrrdeBR8NFe8NLlwe4vxCK3d6PduFYiHoLkhUsx8f0GmhfIwj/CPeQks7TxzboimE8TAr5vb4ySDSlosD0xYbZvro6qaibUOrHhNfvbcz3ldCGC9rsgz/EVkQmjBLNBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15919099002337.6654091893199165; Thu, 11 Jun 2020 14:11:40 -0700 (PDT) Received: from localhost ([::1]:43630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUU6-0001Eu-Gy for importer@patchew.org; Thu, 11 Jun 2020 17:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAW-000265-3r for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34168 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAT-0001Rx-Pj for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-rCM9AFaaOjum2dlsqQ8hqQ-1; Thu, 11 Jun 2020 15:47:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA8B3A0BEB; Thu, 11 Jun 2020 19:47:13 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 498DD60CD3; Thu, 11 Jun 2020 19:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904837; 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=b51M9KztetPMSGfaOOWNQjB7fE1LQXN0ycQf577nQoE=; b=Fskc0Ul5QiUScZmhtn1yJPezK1rRkHNClmzt684E8zrC5P5Ae6l0YcDshBBoG6ZTZ3XVT0 ZjhYl/5FSssU+AL9g5kZzMHXSxMxHW9+Tb7y+lqJWcyUWiU4Df5E1y+v6EbEgJzta3u7jg HnLloZ3xiSUAv5LH9GWI4zmX5oU7rv4= X-MC-Unique: rCM9AFaaOjum2dlsqQ8hqQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 108/115] target/i386: sev: Unify SEVState and SevGuestState Date: Thu, 11 Jun 2020 15:44:42 -0400 Message-Id: <20200611194449.31468-109-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Gibson SEVState is contained with SevGuestState. We've now fixed redundancies and name conflicts, so there's no real point to the nested structure. Just move all the fields of SEVState into SevGuestState. This eliminates the SEVState structure, which as a bonus removes the confusion with the SevState enum. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200604064219.436242-10-david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 79 ++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 24e2dea9b8..d273174ad3 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -35,18 +35,6 @@ =20 typedef struct SevGuestState SevGuestState; =20 -struct SEVState { - uint8_t api_major; - uint8_t api_minor; - uint8_t build_id; - uint64_t me_mask; - int sev_fd; - SevState state; - gchar *measurement; -}; - -typedef struct SEVState SEVState; - /** * SevGuestState: * @@ -70,7 +58,13 @@ struct SevGuestState { =20 /* runtime state */ uint32_t handle; - SEVState state; + uint8_t api_major; + uint8_t api_minor; + uint8_t build_id; + uint64_t me_mask; + int sev_fd; + SevState state; + gchar *measurement; }; =20 #define DEFAULT_GUEST_POLICY 0x1 /* disable debug */ @@ -158,7 +152,7 @@ static bool sev_check_state(const SevGuestState *sev, SevState state) { assert(sev); - return sev->state.state =3D=3D state ? true : false; + return sev->state =3D=3D state ? true : false; } =20 static void @@ -167,9 +161,9 @@ sev_set_guest_state(SevGuestState *sev, SevState new_st= ate) assert(new_state < SEV_STATE__MAX); assert(sev); =20 - trace_kvm_sev_change_state(SevState_str(sev->state.state), + trace_kvm_sev_change_state(SevState_str(sev->state), SevState_str(new_state)); - sev->state.state =3D new_state; + sev->state =3D new_state; } =20 static void @@ -368,7 +362,7 @@ sev_enabled(void) uint64_t sev_get_me_mask(void) { - return sev_guest ? sev_guest->state.me_mask : ~0; + return sev_guest ? sev_guest->me_mask : ~0; } =20 uint32_t @@ -392,11 +386,11 @@ sev_get_info(void) info->enabled =3D sev_enabled(); =20 if (info->enabled) { - info->api_major =3D sev_guest->state.api_major; - info->api_minor =3D sev_guest->state.api_minor; - info->build_id =3D sev_guest->state.build_id; + info->api_major =3D sev_guest->api_major; + info->api_minor =3D sev_guest->api_minor; + info->build_id =3D sev_guest->build_id; info->policy =3D sev_guest->policy; - info->state =3D sev_guest->state.state; + info->state =3D sev_guest->state; info->handle =3D sev_guest->handle; } =20 @@ -507,7 +501,6 @@ sev_read_file_base64(const char *filename, guchar **dat= a, gsize *len) static int sev_launch_start(SevGuestState *sev) { - SEVState *s =3D &sev->state; gsize sz; int ret =3D 1; int fw_error, rc; @@ -535,7 +528,7 @@ sev_launch_start(SevGuestState *sev) } =20 trace_kvm_sev_launch_start(start->policy, session, dh_cert); - rc =3D sev_ioctl(s->sev_fd, KVM_SEV_LAUNCH_START, start, &fw_error); + rc =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_START, start, &fw_error); if (rc < 0) { error_report("%s: LAUNCH_START ret=3D%d fw_error=3D%d '%s'", __func__, ret, fw_error, fw_error_to_str(fw_error)); @@ -566,7 +559,7 @@ sev_launch_update_data(SevGuestState *sev, uint8_t *add= r, uint64_t len) update.uaddr =3D (__u64)(unsigned long)addr; update.len =3D len; trace_kvm_sev_launch_update_data(addr, len); - ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA, + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA, &update, &fw_error); if (ret) { error_report("%s: LAUNCH_UPDATE ret=3D%d fw_error=3D%d '%s'", @@ -582,7 +575,6 @@ sev_launch_get_measure(Notifier *notifier, void *unused) SevGuestState *sev =3D sev_guest; int ret, error; guchar *data; - SEVState *s =3D &sev->state; struct kvm_sev_launch_measure *measurement; =20 if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) { @@ -592,7 +584,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement =3D g_new0(struct kvm_sev_launch_measure, 1); =20 /* query the measurement blob length */ - ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_MEASURE, + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE, measurement, &error); if (!measurement->len) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", @@ -604,7 +596,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) measurement->uaddr =3D (unsigned long)data; =20 /* get the measurement blob */ - ret =3D sev_ioctl(sev->state.sev_fd, KVM_SEV_LAUNCH_MEASURE, + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE, measurement, &error); if (ret) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", @@ -615,8 +607,8 @@ sev_launch_get_measure(Notifier *notifier, void *unused) sev_set_guest_state(sev, SEV_STATE_LAUNCH_SECRET); =20 /* encode the measurement value and emit the event */ - s->measurement =3D g_base64_encode(data, measurement->len); - trace_kvm_sev_launch_measurement(s->measurement); + sev->measurement =3D g_base64_encode(data, measurement->len); + trace_kvm_sev_launch_measurement(sev->measurement); =20 free_data: g_free(data); @@ -628,8 +620,8 @@ char * sev_get_launch_measurement(void) { if (sev_guest && - sev_guest->state.state >=3D SEV_STATE_LAUNCH_SECRET) { - return g_strdup(sev_guest->state.measurement); + sev_guest->state >=3D SEV_STATE_LAUNCH_SECRET) { + return g_strdup(sev_guest->measurement); } =20 return NULL; @@ -642,12 +634,11 @@ static Notifier sev_machine_done_notify =3D { static void sev_launch_finish(SevGuestState *sev) { - SEVState *s =3D &sev->state; int ret, error; Error *local_err =3D NULL; =20 trace_kvm_sev_launch_finish(); - ret =3D sev_ioctl(s->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); if (ret) { error_report("%s: LAUNCH_FINISH ret=3D%d fw_error=3D%d '%s'", __func__, ret, error, fw_error_to_str(error)); @@ -683,7 +674,6 @@ void * sev_guest_init(const char *id) { SevGuestState *sev; - SEVState *s; char *devname; int ret, fw_error; uint32_t ebx; @@ -698,8 +688,7 @@ sev_guest_init(const char *id) } =20 sev_guest =3D sev; - s =3D &sev->state; - s->state =3D SEV_STATE_UNINIT; + sev->state =3D SEV_STATE_UNINIT; =20 host_cpuid(0x8000001F, 0, NULL, &ebx, NULL, NULL); host_cbitpos =3D ebx & 0x3f; @@ -716,20 +705,20 @@ sev_guest_init(const char *id) goto err; } =20 - s->me_mask =3D ~(1UL << sev->cbitpos); + sev->me_mask =3D ~(1UL << sev->cbitpos); =20 devname =3D object_property_get_str(OBJECT(sev), "sev-device", NULL); - s->sev_fd =3D open(devname, O_RDWR); - if (s->sev_fd < 0) { + sev->sev_fd =3D open(devname, O_RDWR); + if (sev->sev_fd < 0) { error_report("%s: Failed to open %s '%s'", __func__, devname, strerror(errno)); } g_free(devname); - if (s->sev_fd < 0) { + if (sev->sev_fd < 0) { goto err; } =20 - ret =3D sev_platform_ioctl(s->sev_fd, SEV_PLATFORM_STATUS, &status, + ret =3D sev_platform_ioctl(sev->sev_fd, SEV_PLATFORM_STATUS, &status, &fw_error); if (ret) { error_report("%s: failed to get platform status ret=3D%d " @@ -737,12 +726,12 @@ sev_guest_init(const char *id) fw_error_to_str(fw_error)); goto err; } - s->build_id =3D status.build; - s->api_major =3D status.api_major; - s->api_minor =3D status.api_minor; + sev->build_id =3D status.build; + sev->api_major =3D status.api_major; + sev->api_minor =3D status.api_minor; =20 trace_kvm_sev_init(); - ret =3D sev_ioctl(s->sev_fd, KVM_SEV_INIT, NULL, &fw_error); + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_INIT, NULL, &fw_error); if (ret) { error_report("%s: failed to initialize ret=3D%d fw_error=3D%d '%s'= ", __func__, ret, fw_error, fw_error_to_str(fw_error)); --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591910017; cv=none; d=zohomail.com; s=zohoarc; b=EMlgmMewsrLZj/tZ1NyolHvy/C9k/P3AE1OssnLJBdlmDt/DV+nGXIVhlCn9iIv+6GkruhEDwYM1M46laqTRxtt6EsQ55MockGSd3dErMiapWczUR3F7UQGLgcAWLb7kCJ9ZoqiS9e5x1GBphTYhgyTLyMje1egCdRBtYGKIL2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591910017; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5CddazxcjvNAzpsqkialJLRkCa+aBUiY9XpNF2aDVNM=; b=KOvE8frJbqn2KJKdTG9+RL641YRR00aCz5w3F/QsTNzCT2NizQvVQb7LITVCWVhxgZ9XsFo4UUWWLz+nT70WQ9RToaRJ4EWZ4i4+yPVw0gHKLxPIRr696tzr6+pzmfXNyuKLmJPVnf73h34PTgozxL9HBLl2tj6u2KhET22v5XA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591910017477407.4960397283659; Thu, 11 Jun 2020 14:13:37 -0700 (PDT) Received: from localhost ([::1]:48628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUW0-0005ML-8e for importer@patchew.org; Thu, 11 Jun 2020 17:13:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAg-0002Fl-Sr for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42381 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAe-0001TD-Tk for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-IOQsulRKNwqJXMz5JWHlUw-1; Thu, 11 Jun 2020 15:47:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A268A107BF0F; Thu, 11 Jun 2020 19:47:24 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 274FF60CC0; Thu, 11 Jun 2020 19:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904847; 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=5CddazxcjvNAzpsqkialJLRkCa+aBUiY9XpNF2aDVNM=; b=exI+TiiutR/PYO2iYDcB5I+lDX53/Ta2WLaBiyViBCwVYMDt37fLB/7Ry9DQCBlUjXwKL0 +wpKOy7sDVijgwWGejI5IKL++G7EMlvSITugZTRufitp+X1LcqyJ2madyEHoGRVNVrlprd UV5ft1vafGySFOPi9gAEJOatgqhx8PA= X-MC-Unique: IOQsulRKNwqJXMz5JWHlUw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 109/115] checkpatch: reversed logic with acpi test checks Date: Thu, 11 Jun 2020 15:44:43 -0400 Message-Id: <20200611194449.31468-110-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Auger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Michael S. Tsirkin" Logic reversed: allowed list should just be ignored. Instead we only take that into account :( Fixes: e11b06a880ca ("checkpatch: ignore allowed diff list") Signed-off-by: Michael S. Tsirkin Message-Id: <20200602053614.54745-1-mst@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0ba213e9f2..2d2e922d89 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1267,7 +1267,7 @@ sub checkfilename { # files and when changing tests. if ($name =3D~ m#^tests/data/acpi/# and not $name =3D~ m#^\.sh$#) { $$acpi_testexpected =3D $name; - } elsif ($name =3D~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { + } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { $$acpi_nontestexpected =3D $name; } if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) { --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908457; cv=none; d=zohomail.com; s=zohoarc; b=OmXVQ9S0OHXh/mDs0fAChAyx+C+caZIOihpunXkGjbcIfWvu2hHR4hfsJGgRqUupNu4IY9MTnJM1dVRSBMul0jxpZAiDWHj0Vcsc8yZbfRS0Ty/viz7TlVM/DtK9MpQ3PGxksC27sc5Id5D3XizYqtnqlQdTVDq5e5FOmM+jEfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hAgpDV7ETO7HWYBmzxQHQly/laq7iYSgNQ/cLQz9mUo=; b=EUT1hDNoVDBatHDrPiLuqtpKwRi13yLVzMtB+u/pnXhIFDpMFmWTDC8PNmHvUA1xYWBx4hQa4jap84LoM/bYjX8F/ypRoc8ytpYjCPT1UFQMoZ6WcJkrMWoogQqFVJVBtjK05wf3kqYv5u2towfuLUlJyNLK0cXu5nVjeDdleJ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908457435461.22351208048224; Thu, 11 Jun 2020 13:47:37 -0700 (PDT) Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU6q-0000F0-A9 for importer@patchew.org; Thu, 11 Jun 2020 16:47:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAi-0002IW-R5 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50625 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAg-0001TR-5M for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-6gHnSJAUO-mlMCOVAUtcRA-1; Thu, 11 Jun 2020 15:47:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC96C107ACCD; Thu, 11 Jun 2020 19:47:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69CCF707C6; Thu, 11 Jun 2020 19:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904849; 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=hAgpDV7ETO7HWYBmzxQHQly/laq7iYSgNQ/cLQz9mUo=; b=GhWR/Kn0i0ZaOoU6pyPxdE20RxGP51PkoiNeZJfVBYj09C+iJKU1GkyODr3qLzZdp+iHTY ffoPv2bnYTFy/8+VHI3ov2TXoniYXpKB5k0QiTbXHibL7WVBpAr6RhZFPz6y+48Wo5yJEJ 1GkZHKDZRO9Fdm46ztf0R09UEFfjIpI= X-MC-Unique: 6gHnSJAUO-mlMCOVAUtcRA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 110/115] exec/memory: Remove unused MemoryRegionMmio type Date: Thu, 11 Jun 2020 15:44:44 -0400 Message-Id: <20200611194449.31468-111-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Since commit 62a0db942dec ('memory: Remove old_mmio accessors') this structure is unused. Remove it. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200601141536.15192-2-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index af8ca7824e..7207025bd4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -50,12 +50,6 @@ extern bool global_dirty_log; =20 typedef struct MemoryRegionOps MemoryRegionOps; -typedef struct MemoryRegionMmio MemoryRegionMmio; - -struct MemoryRegionMmio { - CPUReadMemoryFunc *read[3]; - CPUWriteMemoryFunc *write[3]; -}; =20 typedef struct IOMMUTLBEntry IOMMUTLBEntry; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908794; cv=none; d=zohomail.com; s=zohoarc; b=T/RXnMVAc/RBtYkIZNIExdQMY4cIY7txCKp9pA/4HNLBDJHz8S8YRSWyKamTLhy6pQWAwdX9j9OLnQNcFZFXX6SYlyyNgDb17AV/x/18O+LGMwTB6zQCCpSYqNU9T2edhWOYycSnor+yi5NJrEX1kHB1NIRXMRUMC+4Y9WNnnoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xcbD8i3A9N4avhL5fnu9eOklAsAWnY6vq5+mxC0CfFI=; b=Ne8iaGS0uJP8eF+l2CxYJd6CDLmsmakNBhSxMq4eElYAJy1ekSg4vHCbdjinbMSqikR4JSg5N5WdXPTI9PiJJdXa/wvSiLPX1smdCkkzznylGkf3ymCoAIQospTia++KVWqxXaoU/njulIAWqmbDCV89uVYxtp4vQQKAkA7A57k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908794670331.14673865153964; Thu, 11 Jun 2020 13:53:14 -0700 (PDT) Received: from localhost ([::1]:49740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUCH-0002Xo-DF for importer@patchew.org; Thu, 11 Jun 2020 16:53:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAl-0002M1-1s for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:35 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:49327 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAi-0001U4-Pe for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-4xbkdldbPN6MIkhb0u97zg-1; Thu, 11 Jun 2020 15:47:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2D83A0C01; Thu, 11 Jun 2020 19:47:26 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FA598FF6A; Thu, 11 Jun 2020 19:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904852; 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=xcbD8i3A9N4avhL5fnu9eOklAsAWnY6vq5+mxC0CfFI=; b=GZNkGSuu/cH8RRLQCNNRfHyiNeRLxiR9XtlqoCmiV+b3H+0b7KD1N/T+dDcDaNWpoG5yEe KTfZddFZehFkg2zR2CNV27E6P/09qPJ9O5YmJPvomov4ZadMovqJKr6kFdlLKDUtjIVjnC 8bkRvcVBT8UqP6Zf9XzotzlNyrliIN0= X-MC-Unique: 4xbkdldbPN6MIkhb0u97zg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 111/115] hw/usb: Move device-specific declarations to new 'hcd-musb.h' header Date: Thu, 11 Jun 2020 15:44:45 -0400 Message-Id: <20200611194449.31468-112-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Move the declarations for the MUSB-HDRC USB2.0 OTG compliant core into a separate header. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200601141536.15192-3-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- hw/usb/hcd-musb.c | 1 + hw/usb/tusb6010.c | 1 + include/hw/usb.h | 30 ------------------------- include/hw/usb/hcd-musb.h | 46 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 include/hw/usb/hcd-musb.h diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index c29fbef6fc..5ab13feb3a 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -23,6 +23,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "hw/usb/hcd-musb.h" #include "hw/irq.h" #include "hw/hw.h" =20 diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c index 17580876c6..27eb28d3e4 100644 --- a/hw/usb/tusb6010.c +++ b/hw/usb/tusb6010.c @@ -23,6 +23,7 @@ #include "qemu/module.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "hw/usb/hcd-musb.h" #include "hw/arm/omap.h" #include "hw/hw.h" #include "hw/irq.h" diff --git a/include/hw/usb.h b/include/hw/usb.h index 1cf1cd9584..e2128c7c45 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -474,36 +474,6 @@ bool usb_host_dev_is_scsi_storage(USBDevice *usbdev); =20 #define VM_USB_HUB_SIZE 8 =20 -/* hw/usb/hdc-musb.c */ - -enum musb_irq_source_e { - musb_irq_suspend =3D 0, - musb_irq_resume, - musb_irq_rst_babble, - musb_irq_sof, - musb_irq_connect, - musb_irq_disconnect, - musb_irq_vbus_request, - musb_irq_vbus_error, - musb_irq_rx, - musb_irq_tx, - musb_set_vbus, - musb_set_session, - /* Add new interrupts here */ - musb_irq_max, /* total number of interrupts defined */ -}; - -typedef struct MUSBState MUSBState; - -extern CPUReadMemoryFunc * const musb_read[]; -extern CPUWriteMemoryFunc * const musb_write[]; - -MUSBState *musb_init(DeviceState *parent_device, int gpio_base); -void musb_reset(MUSBState *s); -uint32_t musb_core_intr_get(MUSBState *s); -void musb_core_intr_clear(MUSBState *s, uint32_t mask); -void musb_set_size(MUSBState *s, int epnum, int size, int is_tx); - /* usb-bus.c */ =20 #define TYPE_USB_BUS "usb-bus" diff --git a/include/hw/usb/hcd-musb.h b/include/hw/usb/hcd-musb.h new file mode 100644 index 0000000000..26b50132ff --- /dev/null +++ b/include/hw/usb/hcd-musb.h @@ -0,0 +1,46 @@ +/* + * "Inventra" High-speed Dual-Role Controller (MUSB-HDRC), Mentor Graphics, + * USB2.0 OTG compliant core used in various chips. + * + * Only host-mode and non-DMA accesses are currently supported. + * + * Copyright (C) 2008 Nokia Corporation + * Written by Andrzej Zaborowski + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_USB_MUSB_H +#define HW_USB_MUSB_H + +#include "exec/cpu-common.h" + +enum musb_irq_source_e { + musb_irq_suspend =3D 0, + musb_irq_resume, + musb_irq_rst_babble, + musb_irq_sof, + musb_irq_connect, + musb_irq_disconnect, + musb_irq_vbus_request, + musb_irq_vbus_error, + musb_irq_rx, + musb_irq_tx, + musb_set_vbus, + musb_set_session, + /* Add new interrupts here */ + musb_irq_max /* total number of interrupts defined */ +}; + +extern CPUReadMemoryFunc * const musb_read[]; +extern CPUWriteMemoryFunc * const musb_write[]; + +typedef struct MUSBState MUSBState; + +MUSBState *musb_init(DeviceState *parent_device, int gpio_base); +void musb_reset(MUSBState *s); +uint32_t musb_core_intr_get(MUSBState *s); +void musb_core_intr_clear(MUSBState *s, uint32_t mask); +void musb_set_size(MUSBState *s, int epnum, int size, int is_tx); + +#endif --=20 2.26.2 From nobody Sun May 19 11:31:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591908447; cv=none; d=zohomail.com; s=zohoarc; b=TFgI0RD99fuSsiVZX32rhP6oCHZ2XmO/erd4zpYt2BVlB2s2J7wFoQL3FEMnGlrltNUjsmZBBrO4oSB1Ro1+A+ufcp5AOi86Yhx+Oym76Yt6bF5EQhKQeh51h9juKCCWk3WtoUsS0VTqY/LFLLIkYSlIzHe0RBIA0tsECYbjPG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Teg1bboP42oJzk7SjLIm9ufOGo8EbIsWR0CxjrMPhm4=; b=mXrq0FBgm+XDBKVj1huQvnSpxxp8xWo0vSq/Pb/iqqRVug13z1Xi4rvDUCHmtj99ApqNnJb4rExhJN2P/6H3U3pJGCNqfeKXdB+FZHk3GMJQwEGgxpZbrjMNsHwWaiF1YCbevbc80E39BxiUKfbNqAGEHXekV75Emp/AT2apibs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908447600435.99340179716387; Thu, 11 Jun 2020 13:47:27 -0700 (PDT) Received: from localhost ([::1]:56948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU6g-0008P6-Bi for importer@patchew.org; Thu, 11 Jun 2020 16:47:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAm-0002Ns-6P for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:24163 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAk-0001UK-36 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-WJnJc3NLNBW7Axr37Oyczg-1; Thu, 11 Jun 2020 15:47:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57D5C835B40; Thu, 11 Jun 2020 19:47:27 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C96EF7CCE7; Thu, 11 Jun 2020 19:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904853; 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=Teg1bboP42oJzk7SjLIm9ufOGo8EbIsWR0CxjrMPhm4=; b=ZNDNYQYdhE+tLxBCev4kBe7JfGqoLlmvJgcEqeGAENu7zcjXMCa/bpTrn6ioEej+BOC956 K7O6mqnVE2FenjR3U9vN5rt1F9h08OPUtdofGAKl91Q4DxgHFgnBZh0k8Dn+TSKtbUMgjM 69ghaAeQWCsYQxFChY41Q+cmj+GIIw8= X-MC-Unique: WJnJc3NLNBW7Axr37Oyczg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 112/115] exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h' Date: Thu, 11 Jun 2020 15:44:46 -0400 Message-Id: <20200611194449.31468-113-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:57:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The CPUReadMemoryFunc/CPUWriteMemoryFunc typedefs are legacy remnant from before the conversion to MemoryRegions. Since they are now only used in tusb6010.c and hcd-musb.c, move them to "hw/usb/musb.h" and rename them appropriately. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20200601141536.15192-4-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- hw/usb/hcd-musb.c | 4 ++-- include/exec/cpu-common.h | 3 --- include/hw/usb/hcd-musb.h | 9 +++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index 5ab13feb3a..85f5ff5bd4 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -1540,13 +1540,13 @@ static void musb_writew(void *opaque, hwaddr addr, = uint32_t value) }; } =20 -CPUReadMemoryFunc * const musb_read[] =3D { +MUSBReadFunc * const musb_read[] =3D { musb_readb, musb_readh, musb_readw, }; =20 -CPUWriteMemoryFunc * const musb_write[] =3D { +MUSBWriteFunc * const musb_write[] =3D { musb_writeb, musb_writeh, musb_writew, diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index b47e5630e7..d5e285d2b5 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -43,9 +43,6 @@ extern ram_addr_t ram_size; =20 /* memory API */ =20 -typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); -typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); - void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); /* This should not be used by devices. */ ram_addr_t qemu_ram_addr_from_host(void *ptr); diff --git a/include/hw/usb/hcd-musb.h b/include/hw/usb/hcd-musb.h index 26b50132ff..c874b9f292 100644 --- a/include/hw/usb/hcd-musb.h +++ b/include/hw/usb/hcd-musb.h @@ -13,8 +13,6 @@ #ifndef HW_USB_MUSB_H #define HW_USB_MUSB_H =20 -#include "exec/cpu-common.h" - enum musb_irq_source_e { musb_irq_suspend =3D 0, musb_irq_resume, @@ -32,8 +30,11 @@ enum musb_irq_source_e { musb_irq_max /* total number of interrupts defined */ }; =20 -extern CPUReadMemoryFunc * const musb_read[]; -extern CPUWriteMemoryFunc * const musb_write[]; +/* TODO convert hcd-musb to QOM/qdev and remove MUSBReadFunc/MUSBWriteFunc= */ +typedef void MUSBWriteFunc(void *opaque, hwaddr addr, uint32_t value); +typedef uint32_t MUSBReadFunc(void *opaque, hwaddr addr); +extern MUSBReadFunc * const musb_read[]; +extern MUSBWriteFunc * const musb_write[]; =20 typedef struct MUSBState MUSBState; =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591910084; cv=none; d=zohomail.com; s=zohoarc; b=RmcfUVWnXiWJWJAFEBZRx5RspOfQIVKfLksY3RS9KiW2ePVqc71CFPzDvBJaGqLCVSuH6qY1w7w/IodUQSg/cQbgBCwcezr9JOBrBQ30onootWLLs8X13pM4JSIpCUEPtkOOQxmj8Q/Cd4GnOut6i8UhHpWL84trMxvxy13Jd4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591910084; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jgOHUr86uk5iUKCM5k8xEVjPaQJOtuaVUYx5SmDOBNM=; b=G2ccckubihKGkWzZ7MwxD+AkF00mZVm5FrBbFEPErUfZ8IJ9E/tlc7+HmO7P0P6jkgXoCq4m6D4PnTZf/wB4JOBr3OcH4M3Go/e68wcYDw60bOmUCLS7V2BmYB023gbADAUx8wOndRGsvC0rp7DshKZQ3PQvcUug+fES2a6n4lw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591910084647489.55677474671825; Thu, 11 Jun 2020 14:14:44 -0700 (PDT) Received: from localhost ([::1]:50932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjUX5-0006dD-Ca for importer@patchew.org; Thu, 11 Jun 2020 17:14:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAl-0002Mu-ID for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30043 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAh-0001Tt-TN for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-LwKVlOw4MaORwYjlyQus4g-1; Thu, 11 Jun 2020 15:47:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED25C835B41; Thu, 11 Jun 2020 19:47:27 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F0C98FF6A; Thu, 11 Jun 2020 19:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904851; 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=jgOHUr86uk5iUKCM5k8xEVjPaQJOtuaVUYx5SmDOBNM=; b=DDCW8HBzixor83G59QYN6WWOWKtnqc67GfoMMk0xDt8s/Edr/KA7DI9ULyT2P7BxmqZlaK mQ8mZG77Bfm2vlG9CQQbcYG+PehuZSgXgFDmUgX7/2idpx63GIA4caym1BzDWq/7O27gzV J9mZxEADIdrd4qEGSoD63ETlKvX0CDE= X-MC-Unique: LwKVlOw4MaORwYjlyQus4g-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 113/115] replay: fix replay shutdown for console mode Date: Thu, 11 Jun 2020 15:44:47 -0400 Message-Id: <20200611194449.31468-114-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 14:52:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Dovgalyuk , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk When QEMU is used without any graphical window, QEMU execution is terminated with the signal (e.g., Ctrl-C). Signal processing in QEMU does not include qemu_system_shutdown_request call. That is why shutdown event is not recorded by record/replay in this case. This patch adds shutdown event to the end of the record log. Now every replay will shutdown the machine at the end. Signed-off-by: Pavel Dovgalyuk Message-Id: <159012995470.27967.18129611453659045726.stgit@pasha-ThinkPad-X= 280> Signed-off-by: Paolo Bonzini --- replay/replay.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/replay/replay.c b/replay/replay.c index 706c7b4f4b..7d93746c73 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -366,6 +366,11 @@ void replay_finish(void) /* finalize the file */ if (replay_file) { if (replay_mode =3D=3D REPLAY_MODE_RECORD) { + /* + * Can't do it in the signal handler, therefore + * add shutdown event here for the case of Ctrl-C. + */ + replay_shutdown_request(SHUTDOWN_CAUSE_HOST_SIGNAL); /* write end event */ replay_put_event(EVENT_END); =20 --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908571; cv=none; d=zohomail.com; s=zohoarc; b=RrpGLyJ54PbNH5zqI+gTZU6GNpStiCfSLRUTlJFDhGrmWFMbfI55MVMFBs2lOY47MKCI10eSApne1kN+kGCZcgrDsjB30DP6YSaprcT2oC9A439c93hWgaYP8sndDoeanlkjgQu17D74N3vB45m30s8ZR5HHSzCCaoxqq1hZghI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908571; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yY9bcvZJxaSJ41nPuQZaf5TvXFjXYQELBp993v3BvbI=; b=FyrFZF9J8hbmpbpyZOwYxn2TSIMZTcUP8Z7OxMpI/fWeTR8H2/4iZ5vSOnwyt4ZhrMYi0PNAXwMJg1jhPndo3NsJXWpJig1aa3G2Ta+aY3gwhF5EibaZeX/UMCnEpgZ6hT6Q1lMCaqvr9Z2ejRto5vTlSK+1F9Nk/LPQ9BRKhl4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908571889800.875126235812; Thu, 11 Jun 2020 13:49:31 -0700 (PDT) Received: from localhost ([::1]:37230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU8g-0004hF-Ll for importer@patchew.org; Thu, 11 Jun 2020 16:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAj-0002Jq-PJ for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25685 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAh-0001Tq-M6 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-EQSOtJP2NYKS-ygPgW6rHw-1; Thu, 11 Jun 2020 15:47:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62AE5107ACF2 for ; Thu, 11 Jun 2020 19:47:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F439707C6 for ; Thu, 11 Jun 2020 19:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yY9bcvZJxaSJ41nPuQZaf5TvXFjXYQELBp993v3BvbI=; b=F4xSkRqgegR9YAoqLU8HKjinG7zP8LG8lDStSYBtcP4v0fHJ/XL/Rsjw5p/aNyXuiiUNo4 3ZQQzQ7GMn6yRNvS9d1M4+IZg95tQKQ3i1ysML+biJx03UvyO4s9xAmXrznMQsp/wReaoa 63GOfEJyXuirG82YPjVzdzVpYBlR7Yg= X-MC-Unique: EQSOtJP2NYKS-ygPgW6rHw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 114/115] stubs: move Xen stubs to accel/ Date: Thu, 11 Jun 2020 15:44:48 -0400 Message-Id: <20200611194449.31468-115-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 08:37:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Keep them close to the other accelerator-dependent stubs, so as to remove stubs that are not needed by tools. Signed-off-by: Paolo Bonzini --- accel/stubs/Makefile.objs | 1 + stubs/xen-hvm.c =3D> accel/stubs/xen-stub.c | 14 +++++++------- stubs/Makefile.objs | 2 -- stubs/xen-common.c | 13 ------------- 4 files changed, 8 insertions(+), 22 deletions(-) rename stubs/xen-hvm.c =3D> accel/stubs/xen-stub.c (74%) delete mode 100644 stubs/xen-common.c diff --git a/accel/stubs/Makefile.objs b/accel/stubs/Makefile.objs index 3894caf95d..bbd14e71fb 100644 --- a/accel/stubs/Makefile.objs +++ b/accel/stubs/Makefile.objs @@ -3,3 +3,4 @@ obj-$(call lnot,$(CONFIG_HVF)) +=3D hvf-stub.o obj-$(call lnot,$(CONFIG_WHPX)) +=3D whpx-stub.o obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o obj-$(call lnot,$(CONFIG_TCG)) +=3D tcg-stub.o +obj-$(call lnot,$(CONFIG_XEN)) +=3D xen-stub.o diff --git a/stubs/xen-hvm.c b/accel/stubs/xen-stub.c similarity index 74% rename from stubs/xen-hvm.c rename to accel/stubs/xen-stub.c index 6954a5b696..dcca4e678a 100644 --- a/stubs/xen-hvm.c +++ b/accel/stubs/xen-stub.c @@ -1,18 +1,18 @@ /* - * Copyright (C) 2010 Citrix Ltd. + * Copyright (C) 2014 Citrix Systems UK Ltd. * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - * Contributions after 2012-01-13 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. */ =20 #include "qemu/osdep.h" #include "hw/xen/xen.h" -#include "exec/memory.h" #include "qapi/qapi-commands-misc.h" =20 +void xenstore_store_pv_console_info(int i, Chardev *chr) +{ +} + int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) { return -1; diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index c1e43ac68f..28e48171d1 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -49,7 +49,5 @@ stub-obj-y +=3D target-get-monitor-def.o stub-obj-y +=3D target-monitor-defs.o stub-obj-y +=3D uuid.o stub-obj-y +=3D vm-stop.o -stub-obj-y +=3D xen-common.o -stub-obj-y +=3D xen-hvm.o =20 endif # CONFIG_SOFTMMU || CONFIG_TOOLS diff --git a/stubs/xen-common.c b/stubs/xen-common.c deleted file mode 100644 index f5efcae362..0000000000 --- a/stubs/xen-common.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (C) 2014 Citrix Systems UK Ltd. - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "hw/xen/xen.h" - -void xenstore_store_pv_console_info(int i, Chardev *chr) -{ -} --=20 2.26.2 From nobody Sun May 19 11:31:05 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=1591908564; cv=none; d=zohomail.com; s=zohoarc; b=DMPPtettNdG4QS2V1zjQKFr4+pMLEHMQHTqYAaeyal65sbrTMo2igGFKS0SXvqWdRjlvRjq9ug+vl0b5ckgj+OMJY3Z0ePBWVmThPus2moB6ta3waOq7zJCMIhCin9wtdjdZ1jwQPiP8nZ5PsCbu/RBPBVqYAeS5MOGRlPoBN9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591908564; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VYd0ZjqThto94k0nBBkenZImnLZ41UE3/n5FFwZ4lOs=; b=FZE+oXnqgdVv1l7RfK2lByffvU998lmhcMVHY2nP9LjsfyJ++dT02OAXqmGgRrpPl0x9e+9VU6brP96ROSrBQgSryu/qVBr865JwrCqFSrPW/QVn2LC2JUVxUQ+DfzC/iHdlMiiqVmo2KtNFoqKF2p+zWsiW+wpMRRe6JgUkKi8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591908564806607.7547497706648; Thu, 11 Jun 2020 13:49:24 -0700 (PDT) Received: from localhost ([::1]:36646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjU8Z-0004LQ-Jl for importer@patchew.org; Thu, 11 Jun 2020 16:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjTAt-0002Ta-1o for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48775 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jjTAn-0001Uu-Ci for qemu-devel@nongnu.org; Thu, 11 Jun 2020 15:47:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-h2Ga8VnuMQq-B1IH6rx_Gg-1; Thu, 11 Jun 2020 15:47:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4062A0C03 for ; Thu, 11 Jun 2020 19:47:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 897C1707C6; Thu, 11 Jun 2020 19:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591904856; 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=VYd0ZjqThto94k0nBBkenZImnLZ41UE3/n5FFwZ4lOs=; b=E+1Dh3JQlebNd5a6ChLkvhg0TJ2jfikgtpl0cgf103zNAnt/ytzJv8cJH9YEJrWTkSIctq PSy2EMPppeAzWKPtZswdOPFjVrZIbrkYyS2ho0QHcqWGK/9zy/ZpcIzub9r6X5obqZAwY3 wZglaIaoMVf3zdAopg+tZ/UKbXE2rAw= X-MC-Unique: h2Ga8VnuMQq-B1IH6rx_Gg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 115/115] target/i386: Remove obsolete TODO file Date: Thu, 11 Jun 2020 15:44:49 -0400 Message-Id: <20200611194449.31468-116-pbonzini@redhat.com> In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com> References: <20200611194449.31468-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 03:29:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Thomas Huth The last real change to this file is from 2012, so it is very likely that this file is completely out-of-date and ignored today. Let's simply remove it to avoid confusion if someone finds it by accident. Signed-off-by: Thomas Huth Message-Id: <20200611172445.5177-1-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/TODO | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 target/i386/TODO diff --git a/target/i386/TODO b/target/i386/TODO deleted file mode 100644 index a8d69cf87f..0000000000 --- a/target/i386/TODO +++ /dev/null @@ -1,31 +0,0 @@ -Correctness issues: - -- some eflags manipulation incorrectly reset the bit 0x2. -- SVM: test, cpu save/restore, SMM save/restore.=20 -- x86_64: lcall/ljmp intel/amd differences ? -- better code fetch (different exception handling + CS.limit support) -- user/kernel PUSHL/POPL in helper.c -- add missing cpuid tests -- return UD exception if LOCK prefix incorrectly used -- test ldt limit < 7 ? -- fix some 16 bit sp push/pop overflow (pusha/popa, lcall lret) -- full support of segment limit/rights=20 -- full x87 exception support -- improve x87 bit exactness (use bochs code ?) -- DRx register support -- CR0.AC emulation -- SSE alignment checks - -Optimizations/Features: - -- add SVM nested paging support -- add VMX support -- add AVX support -- add SSE5 support -- fxsave/fxrstor AMD extensions -- improve monitor/mwait support -- faster EFLAGS update: consider SZAP, C, O can be updated separately - with a bit field in CC_OP and more state variables. -- evaluate x87 stack pointer statically -- find a way to avoid translating several time the same TB if CR0.TS - is set or not. --=20 2.26.2