From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 46FF121125000 for ; Thu, 7 Jun 2018 09:07:23 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id v131-v6so20306877wma.1 for ; Thu, 07 Jun 2018 09:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=67c6PTmqmaaJXl98RZz+lCBoTlGnY0K3yNf6TNzBY88=; b=H6T6MGjTtFvp8SoZFNLbJOTervGnvlZELFWsZhgKwszm98yaNryXBetWh/7natfscz KoNlkBDnW6OU+/XM1wwBy9iDcf3BTelc47ZiYJelpQJFd1YOEBeR6WN8c7orDzYZwNiK T1gBDnY1o2kXlYzoxpRfhEYfdN6eyIyKTuW8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=67c6PTmqmaaJXl98RZz+lCBoTlGnY0K3yNf6TNzBY88=; b=K2iof4FV129doBfcojuVnXUkXeeQa0E3aY6/lVmmQ81BPcID81P1NjhAR5JZpGnPXY CIOyPW0upCmoVCgR75cskWnjKt+PL10L/U4Oof/cT0aAb/y1hJ4pmh9u+iHoHWWAZGg8 8G5nt0gu1mTYEF6ClRhXco950qKefM++VjfdPrNxqDFRRh+M/v8dK/IeXkPZF7kQoDhz RhHpmbgKCRIzGMVKQ/stgGeogfC+7o9DM20apzBKjY/uZ8PqPKLxSLHuU0/8BxJXiUgc ZdaFwj66J2ksFxPqG3darIB7tSwYiVDbYExgdGAif5AscgyD++6R633a0Oxx4g0ro9w0 LhkA== X-Gm-Message-State: APt69E14GIWPvewLwxa+y2hsSqbLBte/38YYXE/ps3+7opaGLrM6g9Mt 6hPqWS1jIjMoUvf46WMcYuWCaA== X-Google-Smtp-Source: ADUXVKJRtG75JH5zz2ihj3kv0tRndG/7PO7DFbCRUkarazwEJrrWOARdLiLLE7VoQJnSrtrF23hUgg== X-Received: by 2002:a1c:45db:: with SMTP id l88-v6mr1920397wmi.19.1528387641864; Thu, 07 Jun 2018 09:07:21 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 203-v6sm3000264wmp.23.2018.06.07.09.07.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 09:07:21 -0700 (PDT) Date: Thu, 7 Jun 2018 17:07:19 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, lersek@redhat.com, liming.gao@intel.com, michael.d.kinney@intel.com Message-ID: <20180607160719.aurcs45dscdljvg5@bivouac.eciton.net> References: <20180607104645.22278-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180607104645.22278-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH] MdePkg/BaseIoLibIntrinsic: make BaseIoLibIntrinsic safe for ArmVirt/KVM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 16:07:23 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This addresses all of the items I mentioned in my review of the previous solution to this problem, so for me: Reviewed-by: Leif Lindholm On Thu, Jun 07, 2018 at 12:46:45PM +0200, Ard Biesheuvel wrote: > KVM on ARM refuses to decode load/store instructions used to perform > I/O to emulated devices, and instead relies on the exception syndrome > information to describe the operand register, access size, etc. > This is only possible for instructions that have a single input/output > register (as opposed to ones that increment the offset register, or > load/store pair instructions, etc). Otherwise, QEMU crashes with the > following error > > error: kvm run failed Function not implemented > R00=01010101 R01=00000008 R02=00000048 R03=08000820 > R04=00000120 R05=7faaa0e0 R06=7faaa0dc R07=7faaa0e8 > R08=7faaa0ec R09=7faaa088 R10=000000ff R11=00000080 > R12=ff000000 R13=7fccfe08 R14=7faa835f R15=7faa887c > PSR=800001f3 N--- T svc32 > QEMU: Terminated > > and KVM produces a warning such as the following in the kernel log > > kvm [17646]: load/store instruction decoding not implemented > > The IoLib implementation provided by MdePkg/Library/BaseIoLibIntrinsic > is based on C code, and when LTO is in effect, the MMIO accesses could > be merged with, e.g., manipulations of the loop counter, producing > opcodes that KVM does not support for emulated MMIO. > > So let's add a special ArmVirt flavor of this library that implements > that actual load/store operations in assembler, ensuring that the > instructions involved can be emulated by KVM. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel