From patchwork Thu Jul 30 10:52:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 502064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 82E55140D25 for ; Thu, 30 Jul 2015 20:52:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755298AbbG3Kwe (ORCPT ); Thu, 30 Jul 2015 06:52:34 -0400 Received: from foss.arm.com ([217.140.101.70]:40016 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755273AbbG3Kwd (ORCPT ); Thu, 30 Jul 2015 06:52:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 268B93B0; Thu, 30 Jul 2015 03:52:41 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BBF7D3F21A; Thu, 30 Jul 2015 03:52:31 -0700 (PDT) From: Andre Przywara To: will.deacon@arm.com, kvm@vger.kernel.org Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu, kvm-ppc@vger.kernel.org Subject: [PATCH 06/14] MIPS: use pseek() in ELF kernel image loading Date: Thu, 30 Jul 2015 11:52:23 +0100 Message-Id: <1438253551-2378-7-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1438253551-2378-1-git-send-email-andre.przywara@arm.com> References: <1438253551-2378-1-git-send-email-andre.przywara@arm.com> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Use the newly introduced pseek() function when skipping to the start offset in the ELF file. The layout of an ELF file should satisfy the constraints of pseek, so that we should be able to use a pipe file descriptor as well. Signed-off-by: Andre Przywara --- mips/kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mips/kvm.c b/mips/kvm.c index c1c596c..4d08b20 100644 --- a/mips/kvm.c +++ b/mips/kvm.c @@ -328,8 +328,8 @@ static bool load_elf_binary(struct kvm *kvm, int fd_kernel) kvm->arch.entry_point = ei.entry_point; - if (lseek(fd_kernel, ei.offset, SEEK_SET) < 0) - die_perror("lseek"); + if (!pseek(fd_kernel, ei.offset - sizeof(union ElfHeaders))) + die_perror("seek"); p = guest_flat_to_host(kvm, ei.load_addr);