From patchwork Tue Sep 3 19:12:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 19735 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C0A424869 for ; Tue, 3 Sep 2013 19:12:53 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf6862149vbg.6 for ; Tue, 03 Sep 2013 12:12:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=kwgguGGw/WGnEAIAUTdHpIX6m5AhfQA4nUSgLpg1bZY=; b=TafZ2FKranO2k6QvygBfgVJza/FKq7ou9gJjzOkjxYl3YK1zMW9/bP0H6DYvnE1hWF FtNoYCCAYyjP0C+q9r0CvDUijjWuo43KTAAVy3E5P2n6WqAArVCpynLY891z/m7+ubzm 5yCEkSCs3J9e9EwL7ehjMLHB33RQVZBKSB9+IpfazO8xMUBbHHOEK7iwTelSi7xm6/Dx fpVNK59/uwgKohw80nT+vUQ6Ox17KFFtc/TZUQu5ygLW+1U4mId0tqz4xpRDu5gWKbs5 6IvCgQ94JB1/X6Y3aeBRbJJBj6nFU/BHqPZzRXBcqCjxd+wjRFeemZvPz343gc2QcqA2 v+kA== X-Received: by 10.236.24.195 with SMTP id x43mr10947007yhx.3.1378235573074; Tue, 03 Sep 2013 12:12:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.50.225 with SMTP id f1ls2596697qeo.66.gmail; Tue, 03 Sep 2013 12:12:53 -0700 (PDT) X-Received: by 10.221.32.133 with SMTP id sk5mr1757163vcb.27.1378235572977; Tue, 03 Sep 2013 12:12:52 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id o5si3880377vdw.89.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Sep 2013 12:12:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id c13so4308995vea.24 for ; Tue, 03 Sep 2013 12:12:52 -0700 (PDT) X-Gm-Message-State: ALoCoQl7VVSvuXd/YPNEmucpWn20lcZr9gtUKrEK6Dx1p4Wod/+rZPjA5QCvC3rYyjux/bpREE8l X-Received: by 10.220.164.202 with SMTP id f10mr2734085vcy.25.1378235572850; Tue, 03 Sep 2013 12:12:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp190489vcz; Tue, 3 Sep 2013 12:12:52 -0700 (PDT) X-Received: by 10.180.90.69 with SMTP id bu5mr18277530wib.1.1378235550501; Tue, 03 Sep 2013 12:12:30 -0700 (PDT) Received: from chiark.greenend.org.uk (v6.chiark.greenend.org.uk. [2001:ba8:1e3::]) by mx.google.com with ESMTPS id c6si4248306wiw.16.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Sep 2013 12:12:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pmaydell@chiark.greenend.org.uk designates 2001:ba8:1e3:: as permitted sender) client-ip=2001:ba8:1e3::; Received: by chiark.greenend.org.uk (Debian Exim 4.72 #1) with local (return-path pmaydell@chiark.greenend.org.uk) id 1VGw1Y-0005oe-Q6; Tue, 03 Sep 2013 20:12:24 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Andreas Schwab , Alexander Graf , "Mian M. Hamayun" , kvmarm@lists.cs.columbia.edu, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v6 20/24] linux-user: Allow targets to specify a minimum uname release Date: Tue, 3 Sep 2013 20:12:20 +0100 Message-Id: <1378235544-22290-21-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1378235544-22290-1-git-send-email-peter.maydell@linaro.org> References: <1378235544-22290-1-git-send-email-peter.maydell@linaro.org> Sender: Peter Maydell X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For newer target architectures, glibc can be picky about the kernel version: for example, it will not run on an aarch64 system unless the kernel reports itself as at least 3.8.0. Accommodate this by enhancing the existing support for faking the kernel version so that each target can optionally specify a minimum version: if the user doesn't force a specific fake version then we will override with the minimum required version only if the real host kernel version is insufficient. Use this facility to let aarch64 report a minimum of 3.8.0. Signed-off-by: Peter Maydell --- linux-user/main.c | 2 ++ linux-user/qemu.h | 1 + linux-user/syscall.c | 62 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 28cc58a..d530f01 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3672,6 +3672,8 @@ int main(int argc, char **argv, char **envp) /* Scan interp_prefix dir for replacement files. */ init_paths(interp_prefix); + init_qemu_uname_release(); + if (cpu_model == NULL) { #if defined(TARGET_I386) #ifdef TARGET_X86_64 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4df4fcb..6ffe5a2 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -197,6 +197,7 @@ extern THREAD CPUState *thread_cpu; void cpu_loop(CPUArchState *env); char *target_strerror(int err); int get_osversion(void); +void init_qemu_uname_release(void); void fork_start(void); void fork_end(int child); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 73046b0..180463d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4863,12 +4863,35 @@ int host_to_target_waitstatus(int status) return status; } +static int relstr_to_int(const char *s) +{ + /* Convert a uname release string like "2.6.18" to an integer + * of the form 0x020612. (Beware that 0x020612 is *not* 2.6.12.) + */ + int i, n, tmp; + + tmp = 0; + for (i = 0; i < 3; i++) { + n = 0; + while (*s >= '0' && *s <= '9') { + n *= 10; + n += *s - '0'; + s++; + } + tmp = (tmp << 8) + n; + if (*s == '.') { + s++; + } + } + return tmp; +} + int get_osversion(void) { static int osversion; struct new_utsname buf; const char *s; - int i, n, tmp; + if (osversion) return osversion; if (qemu_uname_release && *qemu_uname_release) { @@ -4878,22 +4901,33 @@ int get_osversion(void) return 0; s = buf.release; } - tmp = 0; - for (i = 0; i < 3; i++) { - n = 0; - while (*s >= '0' && *s <= '9') { - n *= 10; - n += *s - '0'; - s++; - } - tmp = (tmp << 8) + n; - if (*s == '.') - s++; - } - osversion = tmp; + osversion = relstr_to_int(s); return osversion; } +void init_qemu_uname_release(void) +{ + /* Initialize qemu_uname_release for later use. + * If the host kernel is too old and the user hasn't asked for + * a specific fake version number, we might want to fake a minimum + * target kernel version. + */ +#ifdef UNAME_MINIMUM_RELEASE + struct new_utsname buf; + + if (qemu_uname_release && *qemu_uname_release) { + return; + } + + if (sys_uname(&buf)) { + return; + } + + if (relstr_to_int(buf.release) < relstr_to_int(UNAME_MINIMUM_RELEASE)) { + qemu_uname_release = UNAME_MINIMUM_RELEASE; + } +#endif +} static int open_self_maps(void *cpu_env, int fd) {