浏览代码

powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg

Some obvious issues:

cat /proc/ppc64/lparcfg
...
partition_id=16777216
...
partition_potential_processors=268435456

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Anton Blanchard 11 年之前
父节点
当前提交
ca5de4e652
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      arch/powerpc/platforms/pseries/lparcfg.c

+ 6 - 6
arch/powerpc/platforms/pseries/lparcfg.c

@@ -157,7 +157,7 @@ static void parse_ppp_data(struct seq_file *m)
 {
 {
 	struct hvcall_ppp_data ppp_data;
 	struct hvcall_ppp_data ppp_data;
 	struct device_node *root;
 	struct device_node *root;
-	const int *perf_level;
+	const __be32 *perf_level;
 	int rc;
 	int rc;
 
 
 	rc = h_get_ppp(&ppp_data);
 	rc = h_get_ppp(&ppp_data);
@@ -201,7 +201,7 @@ static void parse_ppp_data(struct seq_file *m)
 		perf_level = of_get_property(root,
 		perf_level = of_get_property(root,
 				"ibm,partition-performance-parameters-level",
 				"ibm,partition-performance-parameters-level",
 					     NULL);
 					     NULL);
-		if (perf_level && (*perf_level >= 1)) {
+		if (perf_level && (be32_to_cpup(perf_level) >= 1)) {
 			seq_printf(m,
 			seq_printf(m,
 			    "physical_procs_allocated_to_virtualization=%d\n",
 			    "physical_procs_allocated_to_virtualization=%d\n",
 				   ppp_data.phys_platform_procs);
 				   ppp_data.phys_platform_procs);
@@ -435,7 +435,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
 	int partition_potential_processors;
 	int partition_potential_processors;
 	int partition_active_processors;
 	int partition_active_processors;
 	struct device_node *rtas_node;
 	struct device_node *rtas_node;
-	const int *lrdrp = NULL;
+	const __be32 *lrdrp = NULL;
 
 
 	rtas_node = of_find_node_by_path("/rtas");
 	rtas_node = of_find_node_by_path("/rtas");
 	if (rtas_node)
 	if (rtas_node)
@@ -444,7 +444,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
 	if (lrdrp == NULL) {
 	if (lrdrp == NULL) {
 		partition_potential_processors = vdso_data->processorCount;
 		partition_potential_processors = vdso_data->processorCount;
 	} else {
 	} else {
-		partition_potential_processors = *(lrdrp + 4);
+		partition_potential_processors = be32_to_cpup(lrdrp + 4);
 	}
 	}
 	of_node_put(rtas_node);
 	of_node_put(rtas_node);
 
 
@@ -654,7 +654,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
 	const char *model = "";
 	const char *model = "";
 	const char *system_id = "";
 	const char *system_id = "";
 	const char *tmp;
 	const char *tmp;
-	const unsigned int *lp_index_ptr;
+	const __be32 *lp_index_ptr;
 	unsigned int lp_index = 0;
 	unsigned int lp_index = 0;
 
 
 	seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS);
 	seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS);
@@ -670,7 +670,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
 		lp_index_ptr = of_get_property(rootdn, "ibm,partition-no",
 		lp_index_ptr = of_get_property(rootdn, "ibm,partition-no",
 					NULL);
 					NULL);
 		if (lp_index_ptr)
 		if (lp_index_ptr)
-			lp_index = *lp_index_ptr;
+			lp_index = be32_to_cpup(lp_index_ptr);
 		of_node_put(rootdn);
 		of_node_put(rootdn);
 	}
 	}
 	seq_printf(m, "serial_number=%s\n", system_id);
 	seq_printf(m, "serial_number=%s\n", system_id);